![如何在待机时保留笔记本电脑显示屏的亮度设置?](https://linux22.com/image/883797/%E5%A6%82%E4%BD%95%E5%9C%A8%E5%BE%85%E6%9C%BA%E6%97%B6%E4%BF%9D%E7%95%99%E7%AC%94%E8%AE%B0%E6%9C%AC%E7%94%B5%E8%84%91%E6%98%BE%E7%A4%BA%E5%B1%8F%E7%9A%84%E4%BA%AE%E5%BA%A6%E8%AE%BE%E7%BD%AE%EF%BC%9F.png)
答案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