The Window Order plugin automatically reorders windows in a workspace based on configured priority weights, with larger values positioned further to the left.
[piri.plugins]
window_order = true
[piri.window_order]
enable_event_listener = true # Enable event listening for automatic reordering
default_weight = 0 # Default weight for unconfigured windows
# workspaces = ["1", "2@DP-1", "dev@eDP-1"] # Optional: only apply to specific workspaces (empty = all)
[window_order]
google-chrome = 100
code = 80
ghostty = 70enable_event_listener: Whether to enable event listening. When enabled, windows are automatically reordered when layout changes or new windows open (only works in configuredworkspaces)default_weight: Default weight value for windows not configured in[window_order]workspaces: Optional, specify which workspaces to apply window ordering. Can be workspace names, indices, orname@outputformat (array of strings). If empty or not specified, applies to all workspaces[window_order]: Window weight configuration table, where keys are windowapp_idand values are weights (larger values go to the left)
The plugin supports partial matching:
- Config
ghostty = 70can matchcom.mitchellh.ghostty - Config
google-chrome = 100can matchgoogle-chrome-stable
Matching priority:
- Exact match
- Config key is contained in
app_id app_idis contained in config key- If no match, use
default_weight
piri window_order toggleNote: Manual trigger works in any workspace, regardless of workspaces configuration.
window_order.mp4
If enable_event_listener is enabled, the plugin automatically reorders windows when:
- Window layout changes (
WindowLayoutsChangedevent) - New window opens (
WindowOpenedOrChangedevent)
Note: Automatic trigger only works in workspaces specified in the workspaces configuration. If workspaces is not configured or empty, applies to all workspaces.
window_order_event.mp4
The plugin uses an intelligent algorithm to minimize the number of window moves:
- Get column positions of all tiled windows in the current workspace
- Calculate target position for each window based on configured weights
- Use a greedy algorithm to find the solution with minimum moves
- Move windows to target positions sequentially
- Minimize Moves: Prefer moves that get the most windows to correct positions
- Minimize Distance: Among moves with the same move count, choose the one with minimum distance
- Prefer Focused Window: If only one move is needed, prefer moving the currently focused window
- Preserve Relative Order: Windows with the same weight maintain their current relative order
- ✅ Smart Sorting: Automatically sort windows based on configured weights
- ✅ Minimize Moves: Use optimized algorithm to reduce the number of window moves
- ✅ Partial Matching: Support partial matching of
app_id - ✅ Event-Driven: Optional automatic reordering feature
- ✅ Focus Preservation: Restore original focused window after moves
- ✅ Stable Sort: Windows with the same weight maintain relative order
- Keep frequently used applications (browser, editor) fixed on the left side of the workspace
- Maintain relative order when multiple windows of the same application exist
- Automatically maintain window order through event listening
- Tiled Windows Only: Floating windows are not reordered
- Workspace Filtering:
- Manual Trigger: Works in any workspace, regardless of
workspacesconfiguration - Automatic Trigger: Only works in workspaces specified in
workspacesconfiguration. If not configured or empty, applies to all workspaces
- Manual Trigger: Works in any workspace, regardless of
- Larger Weight = Left: A window with weight 100 will be to the left of a window with weight 80
- Same Weight Preserves Order: Windows with the same weight don't change relative order to reduce unnecessary moves
- Workspace Matching:
workspacessupports workspace names, indices, orworkspace@outputformat (as strings), e.g.,["1", "2@DP-1", "dev@eDP-1"]. The@outputpart supports display prefix matching ("2@DP"matchesDP-1,DP-2, etc.)