https://github.com/H3rmt/hyprswitch
A CLI/GUI that allows switching between windows in Hyprland
https://github.com/H3rmt/hyprswitch
hyprland wayland
Last synced: 13 days ago
JSON representation
A CLI/GUI that allows switching between windows in Hyprland
- Host: GitHub
- URL: https://github.com/H3rmt/hyprswitch
- Owner: H3rmt
- License: mit
- Created: 2023-08-27T20:20:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-24T08:33:05.000Z (6 months ago)
- Last Synced: 2024-10-25T04:30:54.632Z (6 months ago)
- Topics: hyprland, wayland
- Language: Rust
- Homepage: https://crates.io/crates/hyprswitch
- Size: 3.63 MB
- Stars: 198
- Watchers: 3
- Forks: 5
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-hyprland - hyprswitch
README
# hyprswitch
[](https://crates.io/crates/hyprswitch)
[](https://docs.rs/hyprswitch)
[](https://github.com/h3rmt/hyprswitch/actions/workflows/rust.yml)A rust CLI/GUI to switch between windows in [Hyprland](https://github.com/hyprwm/Hyprland)
It can cycle through windows using keyboard shortcuts or/and a GUI.
Windows are sorted by their position on the screen, and can be filtered by class or workspace.
To use the GUI, you need to start the daemon once at the start of Hyprland with `exec-once = hyprswitch init &` in your
config.
Subsequent calls to hyprswitch (with the `gui`, `dispatch` or `close` command) will send the command to the daemon which will execute the
command and update the GUI.
Table of Contents
=================* [Migration to 3.0.0](#migration-to-300)
* [Installation](#installation-hyprland--042-required)
* [From Source](#from-source)
* [Arch](#arch)
* [Nixos](#nixos)
* [Usage](#usage)
* [Parameters](#parameters)
* [Examples](#examples)
* [Features](#features)
* [Theming](#theming---custom-css)
* [Other](#other)
* [Sorting of windows](#sorting-of-windows)
* [Experimental Environment Variables](#experimental-environment-variables)# Migration to 3.0.0
1. The complex Config has been removed in favor of a simpler config.
2. More GUI - CLI options added. (`--mod-key` / `--switch-type` / ...)
3. Removed some cli args. (`--do-initial-execute`, `--stay-open-on-close`)### See [Wiki](https://github.com/H3rmt/hyprswitch/wiki/Migration-from-2.x.x-to-3.0.0) for more details
# Installation (Hyprland >= 0.42 required)
### From Source
- gtk4 and [gtk4-layer-shell](https://github.com/wmww/gtk4-layer-shell) must be installed
- `cargo install hyprswitch`### Arch
- `paru -S hyprswitch` / `yay -S hyprswitch`
### Nixos
- add ``hyprswitch.url = "github:h3rmt/hyprswitch/release";`` to flake inputs
- add `specialArgs = { inherit inputs; };` to `nixpkgs.lib.nixosSystem`
- add `inputs.hyprswitch.packages.x86_64-linux.default` to your `environment.systemPackages`
- available systems: `aarch64-linux`, `i686-linux`, `riscv32-linux`, `riscv64-linux`, `x86_64-linux`# Usage
Once the binary is installed, you can modify your `~/.config/hypr/hyprland.conf`.
## Parameters
### This list only includes the most common options or values, (see `hyprswitch gui --help` / `hyprswitch init --help` / ... for more detailed info)
- `--dry-run / -d` Print the command that would be executed instead of executing it (Daemon/simple doesn't switch, client doesn't send command to daemon)
- `-v` Increase the verbosity level (-v: debug, -vv: trace) (Use [RUST_LOG](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html) env-var for more control)
- `-q` Turn off all output (Except when using `--dry-run`)- `init` Initialize and start the Daemon
- `--custom-css ` Specify a path to custom CSS file
- `--show-title` [default=true] Show the window title instead of its class in Overview (fallback to class if title is empty)
- `--workspaces-per-row` [default=5] Limit amount of workspaces in one row (overflows to next row)
- `--size-factor` [default=6] The size factor (float) for the GUI (original_size / 30 * size_factor)
- `gui` Opens the GUI
- `--mod-key ` [{required}] The modifier key used to open the GUI (super/super_l, super_r, alt/alt_l, alt_r, ctrl/ctrl_l, ctrl_r) (You might want to use a variable, see Examples)
- `--key ` [{required}] The key to used to open the GUI (e.g., tab) (You might want to use a variable, see Examples)
- `--reverse-key =` [default=shift] The key used for reverse switching. Format: reverse-key=mod= or
reverse-key=key= (e.g., --reverse-key=mod=shift, --reverse-key=key=grave)
- `--close ` How to close hyprswitch (`Return` or pressing a window always closes, ESC always kills)
- `default` [default] Close when pressing the `mod key` + `key` again (e.g., SUPER + TAB) or an index key (1, 2, 3, ...)
- `mod-key-release` Close when releasing the `mod key` (e.g., SUPER)- `--max-switch-offset ` [default=6] The maximum offset you can switch to with number keys, use 0 to disable number keys to switch and hide index in GUI
- `--hide-active-window-border` [default=false] Hide the active window border in the GUI (also hides the border for selected workspace or monitor)
- `--monitors` Show the GUI only on this monitor(s) [default: display on all monitors] Example: `--monitors=HDMI-0,DP-1` / `--monitors=eDP-1` Available values: `hyprctl monitors -j | jq '.[].name'`
(You might want to use this together with the next option as using arrow keys to select a window on a different monitor will still be possible. Or use `--filter-current-monitor` to only show windows of the current monitor)
- `--show-workspaces-on-all-monitors` Show all workspaces on all monitors [default: only show workspaces on the corresponding monitor]
- Same options as `simple` except `--offset` and `--reverse`- `simple` Switch without using the GUI / Daemon (switches directly)
- `--reverse / -r` Reverse the order of windows / switch backwards
- `--offset / -o ` Switch to a specific window offset (default 1)- `--include-special-workspaces` Include special workspaces (e.g., scratchpad)
- `--filter-same-class / -s` Only switch between windows that have the same class/type as the currently focused
window
- `--filter-current-workspace / -w` Only switch between windows that are on the same workspace as the currently
focused window
- `--filter-current-monitor / -m` Only switch between windows that are on the same monitor as the currently focused
window
- `--sort-recent` Sort windows by most recently focused
- `--switch-type` Switches to next / previous workspace / client / monitor
- `client` [default] Switch to next / previous client
- `workspace` Switch to next / previous workspace
- `monitor` Switch to next / previous monitor## Examples:
**(Modify the $... variables to use the keys you prefer)**
**It is recommended to keep the `$key` variables to prevent errors when forgetting to change the parameter value when changing the keybinding**
### GUI
**Simple**: Press `super` + `$key(tab)` to open the GUI, use mouse to click on window or press `1` / `2` / ... to switch to index
```ini
exec-once = hyprswitch init --show-title --size-factor 5.5 --workspaces-per-row 5 &$key = tab
$mod = super
bind = $mod , $key, exec, hyprswitch gui --mod-key $mod --key $key --max-switch-offset 9 --hide-active-window-border
```**Simple Arrow keys**: Press `super` + `$key(tab)` to open the GUI, or press `1` / `2` / ... or arrow keys to change selected window, `return` to switch
```ini
exec-once = hyprswitch init --show-title --size-factor 5.5 --workspaces-per-row 5 &$key = tab
$mod = super
bind = $mod, $key, exec, hyprswitch gui --mod-key $mod --key $key --max-switch-offset 9
```**Keyboard (reverse = grave / \` )**: Press `alt` + `$key(tab)` to open the GUI _(and switch to next window)_, hold `alt`, press `$key(tab)` repeatedly to switch to the next window, press ``$reverse(`)`` to switch backwards, release alt to switch
```ini
exec-once = hyprswitch init --show-title &
$key = tab
$mod = alt
$reverse = gravebind = $mod, $key, exec, hyprswitch gui --mod-key $mod --key $key --close mod-key-release --reverse-key=key=$reverse && hyprswitch dispatch
bind = $mod $reverse, $key, exec, hyprswitch gui --mod-key $mod --key $key --close mod-key-release --reverse-key=key=$reverse && hyprswitch dispatch -r# use the if switching to the next window with the opening keypress is unwanted
#bind = alt, $key, exec, hyprswitch gui --mod-key alt_l --key $key --close mod-key-release --reverse-key=key=$reverse
#bind = $mod $reverse, $key, exec, hyprswitch gui --mod-key $mod --key $key --close mod-key-release --reverse-key=key=$reverse
```**Keyboard recent (reverse = grave / \` )**: Press `alt` + `$key(tab)` to open the GUI _(and switch to previously used window)_, hold `alt`, press `$key(tab)` repeatedly to switch to the less and less previously used window, press ``$reverse(`)`` to switch to more recent used windows, release alt to switch
```ini
exec-once = hyprswitch init --show-title &
$key = tab
$mod = alt
$reverse = gravebind = $mod, $key, exec, hyprswitch gui --mod-key $mod --key $key --close mod-key-release --reverse-key=key=$reverse --sort-recent && hyprswitch dispatch
bind = $mod $reverse, $key, exec, hyprswitch gui --mod-key $mod --key $key --close mod-key-release --reverse-key=key=$reverse --sort-recent && hyprswitch dispatch -r# use the if switching to the next window with the opening keypress is unwanted
#bind = $mod, $key, exec, hyprswitch gui --mod-key $mod --key $key --close mod-key-release --reverse-key=key=$reverse
#bind = alt $reverse, $key, exec, hyprswitch gui --mod-key $mod --key $key --close mod-key-release --reverse-key=key=$reverse
```### More Examples in [Wiki](https://github.com/H3rmt/hyprswitch/wiki/Examples)
# Features
- Switch between windows using keyboard shortcuts or/and a GUI
- Customizable Keybindings
- TODO add features to this list## Experimental Features
- Launch applications from the GUI
- Support for plugging in new monitors while running [Only when run as systemd service]
- Automatically restart when version changes [Only when run as systemd service]
- Create all binds and configs from a single config file
- TODO add experimental features to this list# Theming (`--custom-css`)
### CSS Variables
```css
:root {
--border-color: rgba(90, 90, 120, 0.4);
--border-color-active: rgba(239, 9, 9, 0.9);
--bg-color: rgba(20, 20, 20, 1);
--bg-color-hover: rgba(40, 40, 50, 1);
--index-border-color: rgba(20, 170, 170, 0.7);
--border-radius: 12px;
--border-size: 3px;
}
```### Example custom CSS for 4K screen to override default CSS values:
```css
/* light blue borders for active, more transparent bg and more border-radius */
:root {
--border-color-active: rgba(17, 170, 217, 0.9);
--bg-color: rgba(20, 20, 20, 0.8);
--border-radius: 15px;
}/* more margin around image for 4K screen */
.client-image {
margin: 15px;
}/* increased index for 4K screen */
.index {
margin: 10px;
font-size: 25px;
}/* increased font size for 4K screen */
.workspace {
font-size: 35px;
}/* increased font size for 4K screen */
.client {
font-size: 25px;
}
```### See [Wiki](https://github.com/H3rmt/hyprswitch/wiki/CSS) for more info and [Default](src/daemon/gui/defaults.css), [Windows](src/daemon/gui/windows/windows.css) and [Launcher](src/daemon/gui/launcher/launcher.css) for the default Styles
# Other
### Sorting of windows
```
1 2 3 4
1 +------+ +------+
2 | 1 | | 2 |
3 | | +------+
4 +------+ +------+
5 +------+ | 4 |
6 | 3 | | |
7 +------+ +------+
1 2 3 4
``````
Workspace 1 Workspace 2
1 +------+ +------+ | +------+ +------+
2 | 1 | | 2 | | 5 | | 6 |
3 | | | | | | | +------+
4 +------+ +------+ +------+ +------+
5 +------+ +------+ | +------+ | 8 |
6 | 3 | | 4 | | 7 | | |
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
```### Experimental Environment Variables
These variables are subject to change and might be removed in the future (activate debug mode with -v and look for `ENV dump:` in the logs to see the current values or inside the [envs.rs](./src/envs.rs) file)
- `REMOVE_HTML_FROM_WORKSPACE_NAME` bool [default: true]: Remove HTML tag (currently only `{}`) from workspace name
- `SHOW_LAUNCHER` bool [default: true]: Show a Launcher Icon in the GUI when using default `--close` mode
- `LAUNCHER_MAX_ITEMS` i32 [default: 5]: Maximum number of items in the Launcher
- `DEFAULT_TERMINAL` string [default: ""]: Terminal to use for launching terminal applications, e.g., `alacritty`. (If
empty, a list if known terminals is used)
- `DISABLE_TOASTS` bool [default: false]: Disable toasts when errors in the daemon or keybinds are detected