Created
September 7, 2014 21:44
-
-
Save elevendroids/38b5b67fae8c85333bbd to your computer and use it in GitHub Desktop.
Simple init script that saves and restores display brightness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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