答案1
解决此问题的传统方法是创建/etc/pm/sleep.d/10_remember_brightness
包含以下内容的脚本。请注意,该脚本必须可执行(通过chmod +x
命令)并且必须由 root 拥有。
#!/bin/bash
# Description: remember backlight brightness before suspending
case "${1}" in
hibernate|sleep) before_suspend=$(cat /sys/class/backlight/*/brightness )
;;
resume|thaw) echo "$before_suspend" > /sys/class/backlight/*/brightness
;;
esac
如果脚本不能始终跟上并恢复亮度,请使用sleep
如下所示的延迟(sleep
以秒为单位给出的值,0.25 为四分之一秒,根据需要进行调整)
#!/bin/bash
# Description: remember backlight brightness before suspending
case "${1}" in
hibernate|sleep) before_suspend=$(cat /sys/class/backlight/*/brightness )
;;
resume|thaw) sleep 0.25 && echo "$before_suspend" > /sys/class/backlight/*/brightness
;;
esac