6

This has been asked to death, and yet none of the solutions I've found seem to work.

I want to run a command, say setxkbmap -layout us -option ctrl:nocaps , at login. It should only run for me, and not anybody who logs in.

~/.profile doesn't work. ~/.xinitrc doesn't work. ~/.xsession doesn't work. ~/.config/autostart doesn't work.

Edit: Ideally, the solution would also be backup-friendly. Config files are easy to copy, and that's one of the great things about Linux systems.

bfops
  • 163

1 Answers1

5

Most certainly, ~/.config/autostart does work if the command works "normally", but you have to be aware of two possible bottlenecks:

  1. The launcher in ~/.config/autostart is a .desktop file. To run a complicated command from a .desktop file, use the command:

    /bin/bash -c "setxkbmap -layout us -option ctrl:nocaps"
    
  2. Some commands break if they run while the desktop is not fully loaded yet. In that case you'd have to add a little break, e.g.:

    /bin/bash -c "sleep 15&&setxkbmap -layout us -option ctrl:nocaps"
    
Jacob Vlijm
  • 85,475