Revision: 74 http://svn.sourceforge.net/mactel-linux/?rev=74&view=rev Author: ludov Date: 2006-11-30 07:40:56 -0800 (Thu, 30 Nov 2006)
Log Message: ----------- add the "toggle" feature. Thanks to Hannes Wyss for the idea Modified Paths: -------------- trunk/tools/keyboard_brigthness Modified: trunk/tools/keyboard_brigthness =================================================================== --- trunk/tools/keyboard_brigthness 2006-11-30 13:20:17 UTC (rev 73) +++ trunk/tools/keyboard_brigthness 2006-11-30 15:40:56 UTC (rev 74) @@ -20,6 +20,7 @@ #set -v #set -x BRIGHTNESS=/sys/class/leds/smc\:kbd_backlight/brightness +OLD_VALUE=/tmp/keyboard_brigthness_old_value value=$(cat $BRIGHTNESS) if [ -z "$1" ]; then @@ -28,21 +29,39 @@ fi if [ "$1" = "-h" ]; then - echo "Usage: $0 [-h|arg|+arg|-arg]" + echo "Usage: $0 [-h|arg|+arg|-arg|toggle]" echo echo "Change the keyboard brigthness to:" echo " arg" echo " or current value + arg" echo " or current value - arg" + echo " toggle between current brightness value and 0" echo echo "Without argument it return the current value" exit fi -if [ $(expr match "$1" "[+-]") = "1" ]; then - value=$((value$1)) +arg=$1 +if [ $arg = "toggle" ]; then + # get the previous value + if [ -f $OLD_VALUE ]; then + arg=$(cat $OLD_VALUE) + else + arg=0 + fi + + # only toggle to 0 if current value is !=0 + current=$(cat $BRIGHTNESS) + if [ $current -ne 0 ]; then + cp $BRIGHTNESS $OLD_VALUE + arg=0 + fi +fi + +if [ $(expr match "$arg" "[+-]") = "1" ]; then + value=$((value$arg)) else - value=$1 + value=$arg fi if [ $value -lt 0 ]; then This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Mactel-linux-devel mailing list Mactel-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mactel-linux-devel