Sway has many commands for switching the active workspace and focused window. However, I find that most of my window switching comes down to a few simple commands that focus a specific application, or open it first when it has no open windows yet. E.g.:
$mod+s
: open and/or focus slack$mod+i
: open and/or focus signal$mod+m
: open and/or focus emacs$mod+c
: open and/or focus chromium
In addition to this, some apps like emacs have a separate $mod+Shift+m
command that always opens a new window/instance.
The configuration for this is the following:
|
|
Then, for each of these applications, there is a script that tries to focus the application. If the application is not running yet it is started, and if it is running in the background only, a new window is opened.
|
|
For Signal, the script is the same but with variables
|
|
This can also be extended to focus one specific instance of an
application by filtering on title
as well as app_id
.
Back and forth
In addition to the above, it can be nice to quickly switch to the previously active workspace or window.
For workspaces, Sway has the command
|
|
which can be bound to any shortcut.
For switching to previously active windows, I’m using
i3-focus-last
(AUR
package), a window switcher using Rofi that also works with Sway. This
needs exec_always i3-focus-last server
in your Sway config. When
invoked as i3-focus-last menu
, it opens a rofi menu listing all
windows, sorted by most recently focused first.
Previous browser tab using Vimium
With Vimium, you can also switch back to the most recently active tab,
by doing map <key> visitPreviousTab
. You can find some more of my
Vimium config
here.