File ~/.Xmodmap is not sourced on startup in 18.04
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 contentxmodmap ~/.Xmodmap
, as suggested here -
~/.xsession
with contentxmodmap ~/.Xmodmap
, as suggested here -
~/.xsessionrc
with contentxmodmap ~/.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]
Type=Application
Exec=/home/tvbox/bin/modmap
Hidden=false
X-GNOME-Autostart-enabled=true
Name=xmodmap
Comment=xmodmap script
And in /home/tvbox/bin/modmap
, I have:
xmodmap ~/.Xmodmap
I ran into the same problem and found the solution provided by MuadDev worked (on Ubuntu 20.04, but I think this might also apply to 18.04 and up).
In /usr/share/X11/xkb/symbols/pc
Just add the line:
modifier_map Mod3 { Scroll_Lock };
Under the section // Beginning of modifier mappings.
Then you just need to do a reboot, and you're good to go.
Thanks for the hint MuadDev!
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.