cadence’s website.

Some changes will be applied after reloading.
Some changes will be applied after reloading.

Computer niceties

Some time ago I got really annoyed with some ways my computer behaves, so I decided to put in the work to figure out how to fix those annoyances.

Most of these annoyances were things that I had to do manually every time I started my computer. I found that I was keeping my computer powered up for long periods of time so that I didn't have to repeat them.

Login screen keyboard layout

The login screen on Linux is technically known as the "display manager", and there are many different display managers available depending on preference.

Ubuntu seems to use GDM (Gnome Display Manager) by default, which gets the job done, except that I couldn't work out how to change the keyboard layout there. GDM was always using Qwerty, which is frustrating when I don't have the Qwerty layout on my keycaps and don't have it memorised either. The password box masks characters, so I couldn't tell if I hit the wrong key by mistake. Usually I would enable the on-screen keyboard and use it to enter my password.

I solved this problem by installing XDM to replace GDM, because I read online that with XDM we can create a file /etc/X11/xorg.conf.d/90-keyboard.conf with contents:

Section "InputClass"
    Identifier "keyboard-workman"
    MatchIsKeyboard "on"
    MatchDevicePath "/dev/input/event*"
    Driver "evdev"
    Option "XkbLayout" "workman"
EndSection

Now XDM uses the Workman layout.

The default XDM appearance is not to my taste, but I only have to see it for a few seconds, so it won't be worth my time to read how to install a theme.

Disk decryption keyboard layout

I use full disk encryption, including on the root partition.

This makes it really annoying to configure, because there's no X server, and I can't access any real files at that point. I'm also scared of messing something up real bad.

LUKS supports multiple passwords, so as well as my regular password, I also added my password transposed to a different layout.

Here's how to do that

First, use # parted -l to check your partitions. You need to identify where the encrypted partitions are.

The partitions will always end in numbers, like /dev/sda3 or /dev/sdb1.

If you labelled your partitions, you can probably find them easily in that summary. If you didn't, they'll be the partitions that have nothing listed for the "file system" field.

The things you are looking for are not /dev/mapper/* devices!!

Once you've identified your encrypted volumes, carry the following steps out for each of them. I'll use /dev/sda3 as the placeholder, so replace that anywhere it appears.

  1. # cryptsetup luksDump /dev/sda3 to check the status. Might be useful to look at, and compare before/after.
  2. # cryptsetup luksAddKey /dev/sda3 to start adding a new key. Enter any existing passphrase to authorise.
  3. Change your keyboard layout to Qwerty.
  4. Enter the passphrase you want to add, then confirm it. (Since your keyboard is now Qwerty, and it will also be Qwerty when you unlock it, the locations of the keys that you are pressing now will be the same locations when you want to unlock. I pretended that I was using my favourite non-Qwerty layout and entered my password. If you think about this, it should hopefully make sense.)
  5. Change your keyboard layout back.
  6. Check the status again with # cryptsetup luksDump /dev/sda3. You should see an additional key.

Don't forget to do this for all your encrypted partitions, and ensure that all of them include the same passphrase. Because when you enter the passphrase on boot, it attempts to use that passphrase to unlock all disks at the same time. If not all disks have that passphrase, you will have to enter multiple passphrases until you have unlocked every encrypted partition.

PulseAudio output fixes

My 3.5mm output is kind of weird? Like, it doesn't think my headphones are plugged in when they really are, and I think that's the reason that my computer selects the wrong audio device to try to send sound to after I log in. So I have to open pavucontrol and change the output every time.

Apparently I can add some lines to /etc/pulse/default.pa to change the default devices. I've done this, though currently I'm not sure if they work reliably.

Anyway, if you're facing the same problem, the instructions in this post seem reasonable: https://unix.stackexchange.com/a/462671

Openbox startup language

The Openbox startup file, ~/.config/openbox/autostart, seems like it always runs in bash, rather than the user default shell. This makes sense. Something that doesn't make sense is that even if the script has a #! line, it still uses bash.

This piece of code will restart the script if the current shell is not fish. If it is fish, it will continue.

test $FISH_VERSION || exec fish $0

Autostart terminals in another workspace

Various small web programs that I've written need to run in the background after I log in, but I don't really like it if I can't monitor them and stop them easily. Often I need to look at what my code is currently doing, and it's important that I reduce the friction to that as much as possible.

Rather than running the programs headlessly, I now have my Openbox startup file run them in terminal windows, then move the terminal windows off screen to a spare workspace so that I don't have to look at them until I want to.

Now that my startup script is running in fish, it's comfortable to write code that does this. Bash can do it too, but fish is just nice, you know?

set next_terminal_offset 0
function terminal_in_workspace
    set workspace $argv[1]
    set title $argv[2]
    set directory $argv[3]
    set command $argv[4..-1]
    if gnome-terminal --working-directory=$directory --title=$title -- $command
        wmctrl -r $title -t $workspace
        wmctrl -r $title -e 0,(math $next_terminal_offset + 52),(math $next_terminal_offset + 20),-1,-1
        set next_terminal_offset (math $next_terminal_offset + 40)
    end
end

And now, starting a program is as simple as...

terminal_in_workspace 1 homepages /home/cloud/Code/homepages npm run start

Conclusion

My computer is less annoying now. I'm happy when I can shut it down at night, because it no longer resists my efforts to start it up again. Shutting down my computer improves its security and saves power.

I love my computer.

Cadence

A seal on a cushion spinning a globe on its nose.
Another seal. They are friends!