暂停后在Xorg环境中恢复键盘设置

6

我没有使用像Gnome或KDE这样的大型桌面环境,并且使用xset命令来更改键盘速率:

xset r rate 250 70

但是在系统挂起(通过 pm-suspend)后,这些设置会丢失,因为udev会删除并重新添加所有设备。

  1. 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 is not working because xset utility requires some context data which is not available in the evdev context.

  2. I tried to use xorg config, but found only the option to change the keyboard layout, namely XkbLayout and XkbOptions

有没有自动恢复键盘设置的方法,可以在系统暂停后自动进行恢复?
1个回答

5
问题通过添加自定义脚本/etc/pm/sleep.d/00-keyboard得到解决,该脚本会在系统恢复时执行(不仅如此)。
#!/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

更多信息请参见https://wiki.archlinux.org/index.php/Pm-utils#Creating_your_own_hooks

该网站提供有关Pm-utils中创建自己的钩子的详细信息。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接