Swayr

Jul 20, 2023

Urgent-first/LRU window switcher for sway

Swayr consists of a demon, and a client. The demon swayrd records window/workspace creations, deletions, and focus changes using sway’s JSON IPC interface. The client swayr offers subcommands, see swayr –help, and sends them to the demon which executes them.

Right now, there are these subcommands

  • switch-window displays all windows in the order urgent first, then last-recently-used, focused last and focuses the selected.
  • quit-window displays all windows and quits the selected one.
  • switch-to-urgent-or-lru-window switches to the next window with urgency hint if any or to the last recently used window.
  • switch-workspace displays all workspaces in LRU order and switches to the selected one.
  • switch-workspace-or-window displays all workspaces and their windows and switches to the selected workspace or window.
  • quit-workspace-or-window displays all workspaces and their windows and allows to quit either the selected workspace all its windows or the selected window.
  • next-window all-workspaces|current-workspace & prev-window all-workspaces|current-workspace focus the next/previous window in depth-first iteration order of the tree. The argument all-workspaces or current-workspace define if all windows of all workspaces or only those of the current workspace are considered.
  • next-tiled-window & prev-tiled-window do the same as next-window & prev-window but switch only between windows contained in a tiled container.
  • next-tabbed-or-stacked-window & prev-tabbed-or-stacked-window do the same as next-window & prev-window but switch only between windows contained in a tabbed or stacked container.
  • next-floating-window & prev-floating-window do the same as next-window & prev-window but switch only between floating windows.
  • next-window-of-same-layout & prev-window-of-same-layout is like next-floating-window / prev-floating-window if the current window is floating, it is like next-tabbed-or-stacked-window / prev-tabbed-or-stacked-window if the current window is in a tabbed, or stacked container, it is like next-tiled-window / prev-tiled-window if the current windows is in a tiled container, and is like next-window / prev-window otherwise.
  • execute-swaymsg-command displays most swaymsg which don’t require additional input and executes the selected one. That’s handy especially for less often used commands not bound to a key. Non-matching input will be executed executed as-is with swaymsg.
  • execute-swayr-command displays all commands above and executes the selected one. This is useful for accessing swayr commands which are not bound to a key.
  • tile-workspace exclude-floating|include-floating tiles all windows on the current workspace excluding or including floating ones. That’s done by moving all windows away to some special workspace, setting the current workspace to splith layout, and then moving the windows back. If the auto_tile feature is used, see the Configuration section below, it’ll change from splitting horizontally to vertically during re-insertion.
  • shuffle-tile-workspace exclude-floating|include-floating shuffles & tiles all windows on the current workspace. The shuffle part means that a the windows are shuffled before re-insertion, and b a randomly chosen already re-inserted window is focused before re-inserting another window. So while tile-workspace on a typical horizontally oriented screen and 5 windows will usually result in a layout with one window on the left and all four others tiled vertially on the right, shuffle-tile-workspace in combination with auto_tile usually results in a more balanced layout, i.e., 2 windows tiled vertically on the right and the other 4 tiled vertially on the left. If you have less than a handful of windows, just repeat shuffle-tile-workspace a few times until happenstance creates the layout you wanted.
  • tab-workspace exclude-floating|include-floating puts all windows of the current workspace into a tabbed container.
  • toggle-tab-shuffle-tile-workspace exclude-floating|include-floating toggles between a tabbed and tiled layout, i.e., it calls shuffle-tile-workspace if it is currently tabbed, and calls shuffle-tile-workspace if it is currently tiled.
  • move-focused-to-workspace moves the currently focused window or container to another workspace selected with the menu program. Non-matching input of the form #w where the hash and w shortcut are optional can be used to move it to a new workspace.


Checkout these related ports:
  • Zenity - Display GNOME dialogs from the command line
  • Yelp - Help browser for the GNOME desktop
  • Yeahconsole - Terminal wrapper for creating drop-down consoles
  • Yalias - Enhanced execution box with regex pattern matching
  • Yakuake - Drop-down terminal emulator for KDE
  • Yad - Display GNOME dialogs from the command line
  • Xzoom - Magnify, rotate, mirror the image on the X11 screen
  • Xxkb - XKB keyboard layout indicator and switcher
  • Xwud - Image displayer for X
  • Xwit - X interface tool
  • Xwinwrap - XWinWrap replace a desktop background with a movie or screensaver
  • Xwininfo - Window information utility for X
  • Xwd - Dump an image of an X window
  • Xwatchwin - Watch a window on another X server
  • Xvt - Xterm replacement, supporting color, transparency, and more, with less