How to make xmodmap changes permanent?

14,888

Reboot

On the setting panel (KDE/GNOME) there is a startup section where application can be added to startup session, xmodmap can be added there

Resume

Xmodmap does not keep the changes after sleep/resume, here is how to set xmodmap on system resume with systemd: (non systemd user can use this)

  • Create xkeyboard resume script:

    touch /usr/lib/systemd/system-sleep/xkeyboard; chmod 755 /usr/lib/systemd/system-sleep/xkeyboard

  • Edit xkeyboard and fill it with:

#!/bin/bash

case $1 in
    pre)
        exit 0
    ;;
    post)
        export DISPLAY=:0
        sleep 10
        xmodmap -e 'keycode 133 = F14'
    ;;
esac
Share:
14,888

Related videos on Youtube

intika
Author by

intika

Let's make the internet libre https://linuxhacks.org/

Updated on September 18, 2022

Comments

  • intika
    intika over 1 year

    Using xmodmap to remap meta key with the following command:

    xmodmap -e 'keycode 133 = F14'
    

    How can i make the change permanent, especially on system sleep, resume and reboot?

  • Codebling
    Codebling over 4 years
    Can you explain why export DISPLAY=:0 and sleep 10 ?
  • Codebling
    Codebling over 4 years
    Thanks! I ran into a few of those issues myself. In the end I wasted a bunch of time and could not get it to work.
  • NeilG
    NeilG over 2 years
    What about when the keyboard itself disconnects? I have a bluetooth keyboard that "goes to sleep" on an idle time out presumably, and when it comes back, the xmodmap mapping is gone. I'm manually re-applying it at the moment.