Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I designed a keyboard layout for myself, after I run xmodmap it works OK, but after standby or reboot, the layout turn back to qwerty.

How can I set it as default? My OS is Debian Wheezy with XFCE4.

share|improve this question
I have the same problem, debian jessie with xfce4. – John Lawrence Aspden Sep 3 '14 at 16:31

Check out this archlinux forum thread Xmodmap Reset after Suspend to RAM. There are several examples in the thread that'll get you started and show you how to setup a hook which will get triggered via the power management subsystem that will run your xmodmap setup each time you come out of suspend.

Something like the following script, saved as /etc/pm/sleep.d/11suspend (change the me in /bin/su - me to your actual username):

case $1 in
        echo "Hey guy, we are going to suspend to disk!"
        echo "Oh, this time we're doing a suspend to RAM. Cool!"
        echo "oh, suspend is over, we are in $1 phase..."
            # Set Display #
    DISPLAY=:0.0 ; export DISPLAY
    /bin/su - me -c "sleep 3; /usr/bin/xmodmap /home/me/.xmodmaprc" &
    *)  echo "somebody is calling me totally wrong."
share|improve this answer

Premilinary note: you shouldn't use the obsolete xmodmap command, but XKB (xkbcomp).

Then you can change the settings from your ~/.xsession script. Personally I have:

setxkbmap -types local -print | \
  sed -e '/xkb_symbols/s/"[[:space:]]/+local&/' > $HOME/.xkb/keymap/custom
xkbcomp -w0 -I$HOME/.xkb -R$HOME/.xkb keymap/custom $DISPLAY

in my ~/.xsession file, and my XKB settings are put in ~/.xkb/symbols/local and ~/.xkb/types/local files. This will change the settings after each X login.

Unfortunately these settings are lost after suspend/resume. There's a workaround: save them and restore them via pm-utils with a script in the /etc/pm/sleep.d directory; you may need

xhost +si:localuser:root

in your ~/.xsession script since root doesn't have your xauth information. I have given an example (for XKB): https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=633849#92

share|improve this answer
~/.xsession is not being called after resume here. do you know why? – brauliobo Jul 21 '15 at 11:39
@brauliobo ~/.xsession is never executed after resume, just when the X session starts. You need to do xhost +si:localuser:root only at this time. – vinc17 Sep 12 '15 at 0:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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