Skip to content

Instantly share code, notes, and snippets.

@elevendroids
Created September 7, 2014 21:44
Show Gist options
  • Save elevendroids/38b5b67fae8c85333bbd to your computer and use it in GitHub Desktop.
Save elevendroids/38b5b67fae8c85333bbd to your computer and use it in GitHub Desktop.
Simple init script that saves and restores display brightness
#!/bin/sh
### BEGIN INIT INFO
# Provides: brightness
# Required-Start: $local_fs
# Required-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description Provides display brightness persistency on laptop computers
# Description: Provides display brightness persistency on laptop computers
### END INIT INFO
. /lib/lsb/init-functions
N=/etc/init.d/brightness
STATUS_FILE=/etc/acpi/brightness
SYS_FILE=/sys/class/backlight/acpi_video0/brightness
case "$1" in
start)
if [ -e $STATUS_FILE ]; then
cat $STATUS_FILE > $SYS_FILE
fi
;;
stop)
cat $SYS_FILE > $STATUS_FILE
;;
status)
echo "Current brightness level: $(cat $SYS_FILE)"
;;
reload|restart/force-reload)
;;
*)
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1;
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment