8

I upgrade from Ubuntu 15.04 to Ubuntu 15.10 and now on the first boot the keyboard backlight is on. I can manually turn it off, but the setting is not remembered and the next boot results in the keyboard backlight being on.

How can I change the behavior to:

  1. Remember the last setting

or

  1. Default to being off?
1
  • 1
    Link to the related bug report for reference.
    – hg8
    Nov 2 '15 at 9:05
2

Hereafter the script I use at login/resume:
(updated: 21/12/15 + Example of implementation)
(updated: 23/12/15 fix symlink reported command + add launchpad issue ref)
(updated: 23/12/15 less piped + /usr/local/bin)
(updated: 09/01/16 implement on {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
9
  • 2
    Can you append to you answer the instructions for linking this script into /etc/pm/sleep.d? Dec 19 '15 at 17:40
  • I updated it + described implementation
    – r2rien
    Dec 21 '15 at 13:14
  • It should be ln -s /usr/bin/xps13-kbd-backlight /etc/pm/sleep.d/20_xps13-kbd-backlight and I think /usr/local/bin is a better place.
    – pawel7318
    Dec 22 '15 at 23:34
  • oups, fixed symlink command
    – r2rien
    Dec 23 '15 at 9:52
  • for local bin, it's at your convenience but usually it's to override already existing one with your local modifications..wich is not the case here as there isn't any xps13-kbd-backlight executable in /usr/bin
    – r2rien
    Dec 23 '15 at 10:04
1

I have the same problem with my dell Inspiron 7000: the keyboard backlight turns on when it first boots then off then on again at the login screen.

I managed to stop the first by a script in /etc/init.d with the this line:

echo 0 | tee -a /sys/class/leds/dell\:\:kbd_backlight/brightness

But no luck with the second one.

1
  • It seems like the order of the init scripts matter. If you place the same line in the /etc/rc.local it does not work.
    – Ecno92
    Nov 18 '15 at 12:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.