Saturday, February 25, 2023

Another way of swapping alt and ctrl (using xkb)

EDIT: This might not be necessary. Refer to the original post and see updates.

I noitced that the method I described in a previous post does not work on Arch Linux. I came up with this quick (and probably dirty approach) to get the same effect.

First run this command:

xkbcomp $DISPLAY original.xkb

This will dump the current xkb config to a file named original.xkb. Make a copy of this file:

cp original.xkb swapped-alt-ctl.xkb

Edit the newly created swapped-alt-ctl.xkb file. Find the codes for LALT/LCTL and RALT/RCTL and swap them. For example, in my own file I found these for left alt/ctrl:

<LCTL> = 37;
<LALT> = 64;

I changed that to:

<LCTL> = 64;
<LALT> = 37;

Similarly for the right side I changed this:

<RCTL> = 105;
<RALT> = 108;

to:

<RCTL> = 108;
<RALT> = 105;

Then in order to reload the new config, run:

xkbcomp swapped-alt-ctl.xkb $DISPLAY

Put this in an appropriate place, like in your ~/.xinitrc file before the window manager is executed.

There might be a better way of doing this with xkb, but this works for me for now!

Issues with loading swank in stumpwm

 I had this issue that swank would not load when run in .stumpwmrc; SBCL would complain that it can't require "sb-cltl2", even though the package was available when I tried it in an SBCL repl. This comment on github finally made me realize what was happening.

I had to edit my /usr/share/xsessions/stumpwm.desktop file and change the "Exec=" line to this:

Exec=env SBCL_HOME=/usr/lib/sbcl stumpwm

After that, swank would load successfully.