Hi,
I wrote a simple init script to save and restore backlight brightness between 
reboots (have taken urandom as base idea).

If some one wants to try it:
- save the attached script in /etc/init.d and make it executable
- create the wanted sym link in /etc/rc*.d (I suggest rcS.d/S55brightness 
rc0.d/S30brightness rc6.d/S30brightness)
- create the directory /var/lib/backlight where brightenss value will be saved

all this as root naturally.

My two cents ...

Marco
#! /bin/sh
### BEGIN INIT INFO
# Provides:          brightness
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Save and restore brightness between restarts.
# Description:       This script saves the brightness between restarts.
#                    It is called from the boot, halt and reboot scripts.
### END INIT INFO

[ -c /dev/urandom ] || exit 0

PATH=/sbin:/bin
SAVEDFILE=/var/lib/backlight/brightness
. /lib/init/vars.sh

. /lib/lsb/init-functions

do_status () {
        if [ -f $SAVEDFILE ] ; then
                return 0
        else
                return 4
        fi
}

case "$1" in
  start|"")
        [ "$VERBOSE" = no ] || log_action_begin_msg "Restoring backlight 
brightness"
        cat "$SAVEDFILE" >/sys/class/backlight/pwm-backlight/brightness 2>&1
        ES=$?
        [ "$VERBOSE" = no ] || log_action_end_msg $ES
        ;;
  stop)
        # Carry a brightness from shut-down to start-up;
        [ "$VERBOSE" = no ] || log_action_begin_msg "Saving backlight 
brightness"
        cat /sys/class/backlight/pwm-backlight/brightness > "$SAVEDFILE" 2>&1
        ES=$?
        [ "$VERBOSE" = no ] || log_action_end_msg $ES
        ;;
  status)
        do_status
        exit $?
        ;;
  restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
  *)
        echo "Usage: brightness start|stop" >&2
        exit 3
        ;;
esac

:
_______________________________________________
Mailing list: https://launchpad.net/~ac100
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~ac100
More help   : https://help.launchpad.net/ListHelp

Reply via email to