summaryrefslogtreecommitdiff
path: root/debian/src/initscripts/etc/init.d/brightness
diff options
context:
space:
mode:
Diffstat (limited to 'debian/src/initscripts/etc/init.d/brightness')
-rwxr-xr-xdebian/src/initscripts/etc/init.d/brightness68
1 files changed, 68 insertions, 0 deletions
diff --git a/debian/src/initscripts/etc/init.d/brightness b/debian/src/initscripts/etc/init.d/brightness
new file mode 100755
index 00000000..3e22bff8
--- /dev/null
+++ b/debian/src/initscripts/etc/init.d/brightness
@@ -0,0 +1,68 @@
+#!/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 level between restarts.
+# Description: This script saves the brightness level between restarts.
+# It is called from the boot, halt and reboot scripts.
+### END INIT INFO
+readonly SAVEDFILE=/var/lib/initscripts/brightness
+readonly DEFAULT_LEVEL=4
+readonly SYS_CONTROL=/sys/class/backlight/acpi_video0/brightness
+readonly SYS_MAXIMUM=/sys/class/backlight/acpi_video0/max_brightness
+
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
+
+do_status () {
+ MSG="Current brightness level is $(cat ${SYS_CONTROL})"
+ if [ -f $SAVEDFILE ] ; then
+ log_success_msg "${MSG}, saved value is $(cat ${SAVEDFILE})"
+ return 0
+ else
+ log_failure_msg "${MSG}, there is no saved value"
+ return 4
+ fi
+}
+
+do_start () {
+ [ "${VERBOSE}" = no ] ||
+ log_action_begin_msg "Initializing brightness level"
+
+ if [ -f "${SAVEDFILE}" ] ; then
+ cat "${SAVEDFILE}" > "${SYS_CONTROL}"
+ else
+ cat "${SYS_MAXIMUM}" > "${SYS_CONTROL}"
+ fi
+ ES=$?
+
+ [ "${VERBOSE}" = no ] ||
+ log_action_end_msg $ES
+}
+
+do_stop () {
+ [ "${VERBOSE}" = no ] ||
+ log_action_begin_msg "Saving brightness level"
+ cat "${SYS_CONTROL}" > "${SAVEDFILE}"
+ ES=$?
+
+ [ "$VERBOSE" = no ] ||
+ log_action_end_msg $ES
+}
+
+case "$1" in
+ (start) do_start ;;
+ (stop) do_stop ;;
+ (status) do_status ;;
+ (restart|reload|force-reload)
+ echo "Error: argument '$1' not supported" >&2
+ exit 3
+ ;;
+ (*)
+ echo "Usage: brightness start|stop" >&2
+ exit 3
+ ;;
+esac