Sway: tweaks and (un)usual keybindings
When I started to configure Sway, I found a lot of configurations online, but mostly were exactly the same. I too based my configuration on the given example, but disgressed quite a bit.
When I started to configure Sway, I found a lot of configurations online, but mostly were exactly the same. I too based my configuration on the given example, but disgressed quite a bit.
In my Sway configuration I have two lines that start an application in a specific way:
bindsym Mod4+e exec ~/.config/sway/run-or-raise Emacs emacs
bindsym Mod4+w exec ~/.config/sway/run-or-raise Firefox firefox
What does this do?
First, the “exec” clause calls a python script, run-or-raise.
This python scripts wants two arguments. The first one is a container name. It
uses swaymsg -t get_tree
to get all outputs, work spaces and containers. And
then it looks for any container (that is: application, Wayland client) that
matches the name. This match is actually done case insensitive.
When I start Sway, I’d like to have Emacs on the left side of workspace 1, and a terminal (here Alacritty)
on the right side, Unfortunately, this ~/.config/sway/config
except won’t work:
exec emacs
exac alacritty
Because alacritty starts much faster than Emacs. So I’d get the terminal on the right side of the screen. And Emacs on the left. Not good.
Instead, I do this:
exec emacs
for_window [class="^Emacs$"] exec sh -c 'pgrep -x alacritty >/dev/null || alacritty'
for_window [app_id="^emacs$"] exec sh -c 'pgrep -x alacritty >/dev/null || alacritty'
That is, I start Emacs. And I add two for_window
rules that fire when an Sway
container with the named criteria is created. The first line is for Emacs
compiled for X11. And the second line would fire if your Emacs is compiled for
PGTK, which you should only do when you run Emacs under Wayland.
The default rc.lua
from Awesome 4.0 turns title bars on. Here I show
how you can turn them off, and also how I enable them only for
floating clients.
The default rc.lua
from the Awesome window manager uses a lot of
globalkeys = awful.util.table.join(...)
code.
I disliked this because …
So let’s change this …
In this post I show a nice method to define tags and associated layouts, where the tag names change dynamically when the layout changes.
This post shows how you can create a global titlebar. I personally removed the tasklist and replaced this with the titlebar. The tasklist wasn’t good looking anyway and so far I don’t miss the tasklist.
Here are the bash aliases that I like and install almost everywhere.