A Python script to help list and switch sway windows easily through dmenu launchers like fuzzel and rofi.
- Sway
- A dmenu launcher, including fuzzel and rofi
- Python3
- jq
- Grep
Also a nerd font is required if icons not show correctly. You can change fonts in your launcher settings.
-
Get
sway-window-switcher.py
to somewhere you can execute. -
Run
sway-window-switcher.py --help
to get help.> sway-window-switcher.py -h usage: sway-window-switcher.py [-h] [-t {all,floating,scratch,regular}] [--plain-output] [-l {fuzzel,rofi}] List and select windows using swaymsg and dmenu launchers like fuzzel and rofi. options: -h, --help show this help message and exit -t {all,floating,scratch,regular}, --type {all,floating,scratch,regular} Type of window to list. Defaults to "all". --plain-output Print a plain, unbeautified list to dmenu. -l {fuzzel,rofi}, --launcher {fuzzel,rofi} Specific a dmenu launcher to use. Will use first exist launcher if not define.
-
Bind the script to sway keybind to use it easily.
For example, to list all the windows in scratchpad and switch to it you can have this in sway config:
bindsym $mod+x exec sway-window-switcher -t scratch
Make sure
sway-window-switcher
is in you PATH.
-
This script is basically a more featured python rewrite version of codingotaku's script.
-
We used the windowTitleMap from HyprPanel for a better look.