35 lines
666 B
Bash
Executable File
35 lines
666 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Need brightness-udev for non root users to access file
|
|
|
|
file=$(find -L /sys/class/backlight/ -maxdepth 2 -name brightness 2> /dev/null)
|
|
|
|
function inc_brightness() {
|
|
inc=$1
|
|
current=$(cat $file)
|
|
echo $((current + inc)) > $file
|
|
exit
|
|
}
|
|
|
|
function dec_brightness() {
|
|
dec=$1
|
|
current=$(cat $file)
|
|
echo $((current - dec)) > $file
|
|
exit
|
|
}
|
|
|
|
|
|
function main ()
|
|
{
|
|
while [[ $# -ne 0 ]]; do
|
|
arg="$1"; shift
|
|
case "$arg" in
|
|
--inc) val=$1; inc_brightness $val ;;
|
|
--dec) val=$1; dec_brightness $val ;;
|
|
* ) [[ $arg =~ \-+.* ]] && echo "$arg unknown"
|
|
esac
|
|
done
|
|
}
|
|
|
|
main "$@"
|