Commit 39fcf886 authored by askarus's avatar askarus

added pyra-brightkey.sh made by Askarus, improved by sebt3

parent dde62517
#!/bin/sh
help() {
cat <<ENDHELP
$0 {screen|keyboard} {up|down|set|toggle} [value]
ENDHELP
}
case "$1" in
screen|[sS][Cc][rR]*)
FTOG="/var/lib/pyra/screen-toggle-value"
FPAT="/sys/class/backlight/backlight"
minbright=0;;
keyboard|[kK][eE][yY]*)
FTOG="/var/lib/pyra/keyboard-toggle-value"
FPAT="/sys/class/backlight/keyboard-backlight"
minbright=0;;
*) help "$0"
exit 1;;
esac
FCUR="$FPAT/actual_brightness"
FMAX="$FPAT/max_brightness"
FSET="$FPAT/brightness"
curbright="$(cat "$FCUR")"
maxbright="$(cat "$FMAX")"
newbright=$curbright
case "$2" in
set|[sS][eE][tT])
if [ ! $3 ]; then
newbright=$(zenity --scale --text "pick a number" "--min-value=$minbright" "--max-value=$maxbright" "--value=$curbright" --step 1);
else
newbright=$3
fi
if [ ! $newbright ]; then
exit 0
fi;;
up|[uU][pP])
if [ ! $3 ]; then
newbright=$(($curbright+1))
else
newbright=$(($curbright+$3))
fi;;
down|[dD][oO][wW][nN])
if [ ! $3 ]; then
newbright=$(($curbright-1))
else
newbright=$(($curbright-$3))
fi;;
toggle|[tT][oO][gG]*)
if [ $curbright = 0 ]; then
newbright="$( cat $FTOG)"
else
echo $curbright > $FTOG
minbright=0
newbright=0
fi;;
*)
help "$0"
exit 1;;
esac
[ $newbright -le $minbright ] && newbright=$minbright
[ $newbright -ge $maxbright ] && newbright=$maxbright
echo $newbright > $FSET
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment