[i3] where to put xset/setxkbmap commands?


I recently switched from XFCE services + i3 to plain i3 and I’m having trouble persisting some of my keyboard settings.

Basically I want these commands run automatically on startup:

xset r rate 260 55
setxkbmap -option ctrl:nocaps

Anyone know where should I put these in manjaro-i3?



I wrote a small script to keep thinks tidy and stuck a line in the config:

exec ~/.i3/my-xcape.sh

This contains all my keyboard modifications.


That doesn’t work too well – I have to run the script manually every time I plug in a keyboard. Do you know a way to run it apply these settings to all keyboard automatically?


Did you put it in ~/.i3/config <<<<< because that is what is run at startup?


you could put it in your .xinitrc


I’m using a laptop, and solutions mentioned so far doesn’t work when I plug in an external keyboard (I have to run the script manually). Am I missing anything?


do you plug the keyboard in once the laptop is already going? maybe you could look for a way to specify the device name or something like that.


I have never tried this. But your problem seems to be solvable with systemd .device unit files or udev rules. The script would be like @xircon’s, and one or both of these two systems would manage it. You’ll need to learn about them or reformulate the question in a new thread, hoping that someone chimes in who knows how to do it. I can’t investigate at this time.

Without these, I don’t think there is any other way to run the script manually, since you don’t have any other programmable hooks I know of available to you when you plugin a keyboard device. Doing it manually isn’t a big of a problem anyway. It’s not that you plug and unplug your external keyboard like a you were having sex with the USB slot. So, if you end up finding the above methods too complex, don’t feel so bad about running a script manually once or twice per day. Running manual scripts is a normal occurrence among system administrators.


do you plug the keyboard in once the laptop is already going?


Doing it manually isn’t a big of a problem anyway.

It isn’t – I’ve been doing this already on my old system for moths now, but I since I’m reconfiguring my system I thought maybe I could find a better solution. I plug/unplug a keyboard quite often at work (unplug to attend meetings, plug in again afterwards etc.).



Have fun :smiley:


I managed to create a udev rule and I can see my command listed when I try the device using udevdm test ..., but for some reason it doesn’t seem to run when I actually plug in the device… sigh


you could try plugging it in before powering up the laptop and see what happens


Don’t own an external keyboard, so can’t help, but post what you have got, maybe someone can help.