Restore keyboard settings in Xorg after pausing

I do not use huge DEs such as Gnome or KDE, and change the keyboard speed using the xset :

 xset r rate 250 70 

But after the system is suspended (via pm-suspend ), these settings are lost, since udev removes and adds all devices again.

  • I tried to use udev rules:

     # /etc/udev/rules.d/00-custom-keyboard.rules ACTION=="add", SUBSYSTEM=="usb", RUN+="/usr/bin/xset r rate 250 70" # Not working ACTION=="add", SUBSYSTEM=="usb", RUN+="touch /tmp/test" # Working pretty! 

    I think the first rule does not work, because the xset utility requires some contextual data that is not available in the evdev context.

  • I tried using the xorg configuration but found only the ability to change the keyboard layout, namely XkbLayout and XkbOptions

Is there a way to automate the restoration of keyboard settings after a system pause?

+4
source share
1 answer

The problem was solved by adding a custom script /etc/pm/sleep.d/00-keyboard , which is executed (not only) when the system resumes:

 #!/bin/bash case $1 in hibernate) # Going to suspend to disk ;; suspend) # Going to suspend to RAM ;; thaw) # Resuming after hibernating ;; resume) # Resuming after suspending echo "Restoring keyboard settings..." /opt/scripts/keyboard.sh ;; *) echo "Something went wrong" ;; esac 

For more information see https://wiki.archlinux.org/index.php/Pm-utils#Creating_your_own_hooks

+4
source

Source: https://habr.com/ru/post/1492897/


All Articles