I have a custom key mapping in the file ~/.Xmodmap which can be activated by running xmodmap ~/.Xmodmap.

However, I want this to happen automatically when I login. I have tried the following without success:

  • ~/.xinitrc with content xmodmap ~/.Xmodmap, as suggested here
  • ~/.xsession with content xmodmap ~/.Xmodmap, as suggested here
  • ~/.xsessionrc with content xmodmap ~/.Xmodmap, as suggested here

Obviously something is going wrong, but what? And how can I fix this?


Apparently for gnome it should be ~/.xprofile, but that file is executed too early for xmodmap to work.

So I got it to work by creating .config/autostart/xmodmap.desktop

[Desktop Entry]
Comment=xmodmap script

And in /home/tvbox/bin/modmap, I have:

xmodmap ~/.Xmodmap
|improve this answer|||||
  • Thanks! Although I solved it eventually using another method: You can change key behaviour in the following file /usr/share/X11/xkb/symbols/pc – MuadDev Nov 1 '18 at 15:46

I tried the solution found here but somehow it didn't work. After a few days searching and experimenting, finally I found the culprit, i.e. Wayland.

My system is Ubuntu 18.10 and I used to log in per default. However recently I changed to Ubuntu on Wayland at login manager and since then my ~/.Xmodmap stopped working.

As I read on other sites, Wayland uses xkb instead of xmodmap. However it's still cumbersome to configure xkb. So for an average user like me the temporary solution is to switch back to Ubuntu at login screen. I hope this help other people who experience similar issue.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.