#!/bin/sh # script for setting/restoring xps13 kbd backlight state # usable at boot a call within /etc/rc.local # usable at resume|thaw linking it in /etc/pm/sleep.d # from values defined in $BL_CONF # without "#~ " prefix : #~ ## 0 : off #~ ## 1 : min #~ ## 2 : max #~ default=0 #~ current=1 # # 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 # BL_CONF=/etc/xps13-kbd-backlight [ -f $BL_CONF ] || exit 0 BL_SYS=/sys/class/leds/dell::kbd_backlight/brightness BL_CONF_DEFAULT=$(grep ^default $BL_CONF |awk -F = '{print $NF}') BL_CONF_CURRENT=$(grep ^current $BL_CONF |awk -F = '{print $NF}') BL_SYS_CURRENT=$(cat $BL_SYS) #~ echo "BL_CONF_DEFAULT: $BL_CONF_DEFAULT" #~ echo "BL_CONF_CURRENT: $BL_CONF_CURRENT" #~ echo "BL_SYS_CURRENT: $BL_SYS_CURRENT" case "${1}" in suspend|suspend_hybrid|hibernate) # set in conf new current from sys sed -i "s/current=$BL_CONF_CURRENT/current=$BL_SYS_CURRENT/" $BL_CONF ;; resume|thaw) # set from current in conf echo $BL_CONF_CURRENT > $BL_SYS ;; *) # set from default in conf echo $BL_CONF_DEFAULT > $BL_SYS ;; esac