Ubuntu – Unable to get xmodmap working after suspend

startupsuspendxmodmap

I am using Ubuntu 14.04.

I have a custom Xmodmap keyboard layout. However, when I resume after suspend, the layout is gone.

I have tried all things which were mentioned in the answers to this question:
How do I set Xmodmap on login?

Neither using .xinitrc nor adding a command in the startup apps works. Well, they do work after a usual reboot, but not after suspend.

Is there a file that is always execute after loggin in, no matter if it was a reboot or a resume from suspension?

Best Answer

@i08in https://askubuntu.com/a/92235/72576 seems to do the job.

This is what I ended up with on my Debian jessie, KDE.

/etc/pm/sleep.d/20_xmodmap.sh

case "${1}" in
    resume|thaw)
        su $USER -c "sleep 3; /usr/bin/xmodmap /home/$USER/.Xmodmap" &
;;
esac

Note: At first it may seem to not work, but just give it a minute or so. There seems to be something with X that cuses this delay, though I haven't cared enough to check on it... See https://superuser.com/q/626769/185360 for more info.