55 lines
1.4 KiB
Plaintext
55 lines
1.4 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
# set the keyboard brigthness on a Apple MacBook computer
|
||
|
# Copyright (C) 2006 Ludovic Rousseau <ludovic.rousseau@free.fr>
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation; either version 2 of the License, or
|
||
|
# (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License along
|
||
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||
|
|
||
|
#set -v
|
||
|
#set -x
|
||
|
BRIGHTNESS=/sys/class/leds/smc\:kbd_backlight/brightness
|
||
|
value=$(cat $BRIGHTNESS)
|
||
|
|
||
|
if [ -z "$1" ]; then
|
||
|
echo $value
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
if [ "$1" = "-h" ]; then
|
||
|
echo "Usage: $0 [-h|arg|+arg|-arg]"
|
||
|
echo
|
||
|
echo "Change the keyboard brigthness to:"
|
||
|
echo " arg"
|
||
|
echo " or current value + arg"
|
||
|
echo " or current value - arg"
|
||
|
echo
|
||
|
echo "Without argument it return the current value"
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
if [ $(expr match "$1" "[+-]") = "1" ]; then
|
||
|
value=$((value$1))
|
||
|
else
|
||
|
value=$1
|
||
|
fi
|
||
|
|
||
|
if [ $value -lt 0 ]; then
|
||
|
value=0
|
||
|
fi
|
||
|
|
||
|
echo $value > $BRIGHTNESS
|
||
|
cat $BRIGHTNESS
|
||
|
|