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.

2

1 Answer 1

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"
    
2
  • Perfect, getting it to run through bash was the key. Thanks!
    – bfops
    May 17, 2015 at 14:40
  • @bfops always nice when things start to work :) May 17, 2015 at 14:40

You must log in to answer this question.

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