2

I have verified that .profile is executed on login.

However, commands involving setxkbap (e.g. setxkbmap -option ctrl:swapcaps) and xcape (e.g. xcape -e 'Control_L=Escape') seem to be ignored.

Since both programs are for keyboard bindings I figured the reasons they are ignored is related. How can I get them to run on login?

Using Ubuntu 22.04 on Xorg (xcape doesn't work on Wayland).

5
  • Probably better to use Tweaks (you may need to install gnome-tweaks) to change the keyboard behavior in this respect. Jun 4, 2023 at 11:54
  • @GunnarHjalmarsson Unfortunately it is impossible to replicate the behaviour of xcape with gnome-tweaks.
    – Rosa
    Jun 4, 2023 at 15:33
  • Maybe that particular combo is not so easy... Another thought is to put those commands in a shell script and autostart that script at login. Jun 4, 2023 at 16:00
  • @GunnarHjalmarsson I managed to do it by using startup applications, but I had to run them as a script with a delay of a few seconds (sleep 10). If you want to put this in an answer I will mark it as solved to help others. Thanks.
    – Rosa
    Jun 4, 2023 at 16:31
  • Great! Please feel free to use it in an own answer. It's perfectly fine to answer your own question. ;) Jun 4, 2023 at 16:41

1 Answer 1

2

This can done with Startup Applications.

Put your commands in a file with a delay command at the top (this is because keyboard bindings need the desktop environment to be loaded before they can be executed):

sleep 10;
setxkbmap ...;
xcape ...;

Save this as keybinds.sh then in Startup Applications click Add and in the popup dialogue, add this in the Command field (just change the location of keybinds script).

/bin/bash -c "sh /home/user/.../keybinds.sh"

When you login, after 10 seconds the script will run.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .