Permalink
Browse files

brightness: can also show current brightness

  • Loading branch information...
1 parent 42722cc commit 4761af5838b1ed7b0edc93c983842359740efff3 @tpo committed Jun 16, 2013
Showing with 23 additions and 11 deletions.
  1. +2 −2 README.md
  2. +21 −9 brightness
View
@@ -4,9 +4,9 @@ Here's the --help for each shell script:
### brightness
-usage: brightness [percent]
+usage: brightness [--show|percent]
- set panel brightness on intel chips in percent (default ist 60%)
+ set or show panel brightness on intel chips in percent (default ist 60%)
### catwhich
View
@@ -1,22 +1,34 @@
#!/bin/bash
help() {
- echo 'usage: brightness [percent]'
+ echo 'usage: brightness [--show|percent]'
echo
- echo ' set panel brightness on intel chips in percent (default ist 60%)'
+ echo ' set or show panel brightness on intel chips in percent (default ist 60%)'
echo
exit
}
if [ "$1" == "--help" ]; then
help
-elif [ -z "$1" ]; then
- percent=60
-else
- percent=$1
fi
max=$( cat /sys/class/backlight/intel_backlight/max_brightness )
-want=$(( $max / 100 * $percent ))
-sudo sh -c "echo $want > /sys/class/backlight/intel_backlight/brightness"
-echo "set brightness to $percent"
+
+if [ "$1" == "--show" ]; then
+ current=$( cat /sys/class/backlight/intel_backlight/brightness )
+ percent=$(( $current * 100 / $max ))
+ echo "current brightness is $percent%"
+ exit 0
+else
+
+ if [ -z "$1" ]; then
+ percent=60
+ else
+ percent=$1
+ fi
+
+ want=$(( $max / 100 * $percent ))
+ sudo sh -c "echo $want > /sys/class/backlight/intel_backlight/brightness"
+ echo "set brightness to $percent"
+ exit 0
+fi

0 comments on commit 4761af5

Please sign in to comment.