summaryrefslogtreecommitdiff
path: root/packages/display-brightness/display-brightness.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packages/display-brightness/display-brightness.sh')
-rw-r--r--packages/display-brightness/display-brightness.sh12
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/display-brightness/display-brightness.sh b/packages/display-brightness/display-brightness.sh
index 4e706e1e75..5e1a0e97d4 100644
--- a/packages/display-brightness/display-brightness.sh
+++ b/packages/display-brightness/display-brightness.sh
@@ -7,11 +7,17 @@
STEP=5
-DRIVER="`ls /sys/class/backlight/|head -1`"
+DRIVER="`ls /sys/class/backlight/|head -n 1`"
MAX_BRIGHTNESS=`cat /sys/class/backlight/$DRIVER/max_brightness`
ACTUAL_BRIGHTNESS=`cat /sys/class/backlight/$DRIVER/actual_brightness`
BRIGHTNESS_FILE="/sys/class/backlight/$DRIVER/brightness"
+if test "$1" != "up" -a "$1" != "down" -a -n "$1"
+then
+ echo -e "\nUsage:\n\t `basename $0` [up | down]\n"
+ exit 0
+fi
+
echo "max / current"
echo "$MAX_BRIGHTNESS / $ACTUAL_BRIGHTNESS"
if [ ! -n "$1" ]; then
@@ -22,7 +28,8 @@ if [ "$1" = "up" ]; then
if [ $ACTUAL_BRIGHTNESS -eq $MAX_BRIGHTNESS ]; then
exit 0
else
- let CURRENT_BRIGHTNESS=$ACTUAL_BRIGHTNESS+$STEP
+ test "$STEP" -gt "$MAX_BRIGHTNESS" -o "$STEP" -eq "$MAX_BRIGHTNESS" && STEP=1
+ let CURRENT_BRIGHTNESS=$ACTUAL_BRIGHTNESS+$STEP
echo $CURRENT_BRIGHTNESS >> $BRIGHTNESS_FILE
exit 0
fi
@@ -42,3 +49,4 @@ if [ "$1" = "down" ]; then
exit 0
fi
fi
+