#hyprland #window #wayland #switching #switch #applications #sorting

bin+lib window_switcher

A CLI that allows switching between windows in Hyprland (renamed to hyprswitch [https://crates.io/crates/hyprswitch])

8 releases

0.3.0 Feb 3, 2024
0.2.1 Dec 18, 2023
0.1.6 Oct 25, 2023
0.1.3 Sep 8, 2023
0.1.2 Aug 27, 2023

#2079 in Command line utilities

Download history 30/week @ 2024-09-21 19/week @ 2024-09-28

67 downloads per month

MIT and GPL-3.0-or-later

25KB
383 lines

hyprswitch

crates.io Docs Tests

A small rust CLI tool to switch between windows in hyperland.

It can switch through all windows or only windows of same class(= application) in regular or reverse order.

Installation

cargo install hyprswitch

Usage

Once the binary is installed, you can modify your ~/.config/hypr/hyprland.conf.

Here are some samples:

  • simple config
# switches to next window
bind = ALT, TAB, exec, $HOME/.cargo/bin/hyprswitch

# switches to next window of same class
bind = ALT CTRL, TAB, exec, $HOME/.cargo/bin/hyprswitch --same-class

# switches to next window in workspace
bind = SUPER, TAB, exec, $HOME/.cargo/bin/hyprswitch --stay-workspace
  • with reverse binds
# switches to next window
bind = ALT, TAB, exec, $HOME/.cargo/bin/hyprswitch

# switches to next window in reverse order
bind = ALT SHIFT, TAB, exec, $HOME/.cargo/bin/hyprswitch --reverse


# switches to next window in workspace
bind = SUPER, TAB, exec, $HOME/.cargo/bin/hyprswitch --stay-workspace

# switches to next window in workspace in reverse order
bind = SUPER, TAB, exec, $HOME/.cargo/bin/hyprswitch --stay-workspace --reverse


# switches to next window of same class
bind = ALT CTRL, TAB, exec, $HOME/.cargo/bin/hyprswitch --same-class

# switches to next window of same class in reverse order
bind = ALT CTRL SHIFT, TAB, exec, $HOME/.cargo/bin/hyprswitch --reverse --same-class

The script accepts 5 parameters:.

  • --same-class Switch between windows of same class (type)
  • --reverse Reverse the order of the windows
  • --stay-workspace Restrict cycling of windows to current workspace
  • --ignore-workspace Ignore workspaces and sort like one big workspace for each monitor
  • --ignore-monitor Ignore monitors and sort like one big monitor, workspaces must have offset of 10 for each monitor
  • --vertical-workspaces will treat workspaces as vertical aligned (used with --ignore-workspace)
  • --sort-recent will sort windows by recently visited instead of position

Sorting of windows

See tests for more details on how windows get sorted

   1      2  3      4
1  +------+  +------+
2  |  1   |  |  2   |
3  |      |  +------+
4  +------+  +------+
5  +------+  |  3   |
6  |  4   |  |      |
7  +------+  +------+
   1      2  3      4
                  Monitor 1
      Workspace 1           Workspace 2
1  +------+  +------+ | +------+  +------+
2  |  1   |  |  2   |   |  5   |  |  6   |
3  |      |  |      | | |      |  +------+
4  +------+  +------+   +------+  +------+
5  +------+  +------+ | +------+  |  7   |
6  |  3   |  |  4   |   |  8   |  |      |
7  +------+  +------+ | +------+  +------+
   1      2  3      4   1      2  3      4
      1       3    5   6     8   10  11  12
   +----------------------------------------+
1  |  +-------+                      +---+  |
2  |  |   1   |              +---+   | 5 |  |
3  |  |       |    +---+     | 3 |   |   |  |
4  |  +-------+    | 2 |     +---+   |   |  |
5  |               +---+     +---+   |   |  |
6  |                         | 4 |   |   |  |
7  |    +-------+            +---+   +---+  |
8  |    |   6   |         +----+            |
9  |    |       |         | 7  |            |
10 |    +-------+         +----+            |
   +----------------------------------------+
        2       4         7    9

Ignore monitors flag

This flag requires that workspaces have an offset of 10 for each monitor. (TODO, make this configurable)

This means that if you have 2 monitors, the workspaces on the second monitor must start at 11 if the first workspace on the first monitor is 1.

this can be configured in ~/.config/hypr/hyprland.conf (https://wiki.hyprland.org/Configuring/Workspace-Rules/)

Dependencies

~7–15MB
~183K SLoC