Linux

Sway: Application startup via run-or-raise

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.

Sway: default initial layout

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.

AwesomeWM: Alternative bindings setup

The default rc.lua from the Awesome window manager uses a lot of globalkeys = awful.util.table.join(...) code.

I disliked this because …

  • in Lua, the last field of a table cannot have a comma. So often when I moved an entry around, I ended up with a pointless syntax error because of a missing or trailing comma
  • adding elements by joining seems somewhat complex
  • adding logic, e.g. only adding a keybinding under specific circumstances is suddenly more difficult

So let’s change this …

Blogging with Hugo

I wrote my home page with various tools …

Pure HTML

At the beginning, I used HTML and .shtml include files

Apache was told to process html include files, and I had the boilerplate and bottom in such files and included them from the per-page HTML files.

Webber

Later I switched to Webber. That was a python written open-source software that I published on gitorious.org. The original gitorious is now down, but you find the git tree still at https://gitorious.org/webber/webber, where an archive team resurrected the public git trees.

Serial setup with C-Kermit

When you work with embedded devices (e.g. SabreLite, Arduino, Raspberry Pi) you often need to work over a serial port, e.g. to customize the Barebox or U-Boot boot loader.

On Linux, people often use “minicom” for this. Other options are “Putty” (yes, it’s not a Windows-only program, try “apt-get install putty”) or even the ancient C-Kermit. Surprisingly I found that Kermit suits my work-flow the best, when properly configured.