我从 Ubuntu 15.04 升级到 Ubuntu 15.10,现在第一次启动时键盘背光亮起。我可以手动将其关闭,但设置没有被记住,下次启动时键盘背光会亮起。
我怎样才能将行为改变为:
- 记住上次设置
或者
- 默认关闭?
答案1
此后,我在登录/恢复时使用的脚本:(
更新:21/12/15 +实施示例)
(更新:23/12/15 修复符号链接报告的命令 + 添加启动板问题参考)
(更新:23/12/15 减少管道 + /usr/local/bin)
(更新:09/01/16 在 {ac|battery} 上实施
#!/bin/sh
#
# script for setting/restoring xps13 kbd backlight state
#
# Cf https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1510344
# Cf http://askubuntu.com/questions/689907/dell-xps-13-9343-keyboard-backlight-on-at-boot-ubuntu-15-10
# Copyright: Copyright (c) 2015 r2rien
# License: GPL-2
#
## Exemple of implementation:
#
# saved as executable in:
# [/usr/local/bin/xps13-kbd-backlight]
#
# using preferences set in ${BL_CONF}
# [/etc/xps13-kbd-backlight]
# (without "#~ " prefix)
#~ ## 0 : off
#~ ## 1 : min
#~ ## 2 : max
#~ default=0
#~ current=1
#~ on_ac=2
#
# usable at login from desktop file:
# [/etc/xdg/autostart/xps13-kbd-backlight.desktop]
# (without "#~ " prefix)
#~ [Desktop Entry]
#~ Version=1.0
#~ Type=Application
#~ Terminal=false
#~ Exec=xps13-kbd-backlight
#~ X-GNOME-Autostart-enabled=true
#~ X-GNOME-Autostart-Phase=Initialization
#~ Icon=keyboard
#~ Name=xps13-kbd-backlight
#~ Comment=set/restore xps13-kbd-backlight
#~ Categories=Utility;
#
# usable at resume|thaw linking it in /etc/pm/sleep.d
# [ln -s /usr/local/bin/xps13-kbd-backlight /etc/pm/sleep.d/20_xps13-kbd-backlight]
#
# usable at on_battery|on_ac linking it in /etc/pm/power.d
# [ln -s /usr/local/bin/xps13-kbd-backlight /etc/pm/power.d/20_xps13-kbd-backlight]
BL_CONF=/etc/xps13-kbd-backlight
[ -f ${BL_CONF} ] || exit 0
BL_SYS=/sys/class/leds/dell::kbd_backlight/brightness
BL_SYS_CURRENT=$(cat ${BL_SYS})
BL_CONF_CURRENT=$(awk -F = '/^current/ {print $NF}' ${BL_CONF})
BL_CONF_DEFAULT=$(awk -F = '/^default/ {print $NF}' ${BL_CONF})
BL_CONF_ON_AC=$(awk -F = '/^on_ac/ {print $NF}' ${BL_CONF})
case "${1}" in
suspend|suspend_hybrid|hibernate)
# save in conf new current from sys
sudo sed -i "s/current=${BL_CONF_CURRENT}/current=${BL_SYS_CURRENT}/" ${BL_CONF}
;;
resume|thaw)
# set from current in conf
echo ${BL_CONF_CURRENT} |sudo tee ${BL_SYS}
;;
true)
# on battery power:
# set from current in conf
echo ${BL_CONF_CURRENT} |sudo tee ${BL_SYS}
;;
false)
# on ac power:
# save in conf new current from sys and set from on_ac in conf
sudo sed -i "s/current=${BL_CONF_CURRENT}/current=${BL_SYS_CURRENT}/" ${BL_CONF}
echo ${BL_CONF_ON_AC} |sudo tee ${BL_SYS}
;;
*)
# set from default in conf
echo ${BL_CONF_DEFAULT} |sudo tee ${BL_SYS}
;;
esac
答案2
我的戴尔 Inspiron 7000 也遇到了同样的问题:首次启动时键盘背光亮起,然后熄灭,在登录屏幕上再次亮起。
我设法通过/etc/init.d
以下行脚本停止了第一个:
echo 0 | tee -a /sys/class/leds/dell\:\:kbd_backlight/brightness
但第二个就没那么幸运了。