Skip to content
Snippets Groups Projects
Commit f0381a86 authored by askarus's avatar askarus
Browse files

added 'pyra-brightkey.sh'. It includes all functionaity for the brightness key

parent 2167db67
No related branches found
No related tags found
No related merge requests found
README 100644 → 100755
......@@ -5,8 +5,16 @@ Pyra Zenity scripts for
brightness and settings
pyra-brightkey.sh is fo everything needed for the brightness key
1st argument: sreen/keyboard
2nd argument: up/down/set/toggle
3rd argument: optional, must be a didget, sets/increases/decreases the brightness
If no 3rd argument is set, value isincreased/decreased by 1.
"set" without an argument opens a zenity dialog
NOTE:
1. LCD brightness can not be set to "0" to prevent a black screen. That can and will be changed later.
2. The "pyra-keyboard-toggle.sh" script does create a file in /var/lib/pyra
1. The "pyra-keyboard-toggle.sh" script does create a file in /var/lib/pyra
Here the previous brightness level is stored and overwritten if necessary
#!/bin/sh
if [ $1 = "screen" ]; then
if [ $2 = "set" ]; then
minbright=1
maxbright="$(cat /sys/devices/platform/backlight/backlight/backlight/max_brightness)"
curbright="$(cat /sys/devices/platform/backlight/backlight/backlight/actual_brightness)"
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
if [ $newbright -le $minbright ]; then newbright=$minbright; fi
if [ $newbright -ge $maxbright ]; then newbright=$maxbright; fi
echo $newbright > /sys/devices/platform/backlight/backlight/backlight/brightness
fi
elif [ $2 = "up" ]; then
maxbright="$(cat /sys/devices/platform/backlight/backlight/backlight/max_brightness)"
curbright="$(cat /sys/devices/platform/backlight/backlight/backlight/actual_brightness)"
if [ ! $3 ]; then
if [ $curbright = $maxbright ]; then
newbright=$maxbright
else
newbright=$(($curbright+1))
fi
else
newbright=$(($curbright+$3))
if [ $newbright -gt $maxbright ]; then
newbright=$maxbright
fi
fi
echo $newbright > /sys/devices/platform/backlight/backlight/backlight/brightness
elif [ $2 = "down" ]; then
minbright=0
curbright="$(cat /sys/devices/platform/backlight/backlight/backlight/actual_brightness)"
if [ ! $3 ]; then
if [ "$curbright" = "$minbright" ]; then
newbright=$minbright
else
newbright=$(($curbright-1))
fi
else
newbright=$(($curbright-$3))
if [ $newbright -lt $minbright ]; then
newbright=$minbright
fi
fi
echo $newbright > /sys/devices/platform/backlight/backlight/backlight/brightness
elif [ $2 = "toggle" ]; then
curbright="$(cat /sys/devices/platform/backlight/backlight/backlight/actual_brightness)"
if [ $curbright = 0 ]; then
newbright="$( cat /var/lib/pyra/screen-toggle-value)"
else
echo $curbright > /var/lib/pyra/screen-toggle-value
newbright=0
fi
echo $newbright > /sys/devices/platform/backlight/backlight/backlight/brightness
fi
elif [ $1 = "keyboard" ]; then
if [ $2 = "set" ]; then
minbright=0
maxbright="$(cat /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/max_brightness)"
curbright="$(cat /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/actual_brightness)"
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
if [ $newbright -le $minbright ]; then newbright=$minbright; fi
if [ $newbright -ge $maxbright ]; then newbright=$maxbright; fi
echo $newbright > /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/brightness
fi
elif [ $2 = "up" ]; then
maxbright="$(cat /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/max_brightness)"
curbright="$(cat /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/actual_brightness)"
if [ ! $3 ]; then
if [ $curbright = $maxbright ]; then
newbright=$maxbright
else
newbright=$(($curbright+1))
fi
else
newbright=$(($curbright+$3))
if [ $newbright -gt $maxbright ]; then
newbright=$maxbright
fi
fi
echo $newbright > /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/brightness
elif [ $2 = "down" ]; then
minbright=0
curbright="$(cat /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/actual_brightness)"
if [ ! $3 ]; then
if [ "$curbright" = "$minbright" ]; then
newbright=$minbright
else
newbright=$(($curbright-1))
fi
else
newbright=$(($curbright-$3))
if [ $newbright -lt $minbright ]; then
newbright=$minbright
fi
fi
echo $newbright > /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/brightness
elif [ $2 = "toggle" ]; then
curbright="$(cat /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/actual_brightness)"
if [ $curbright = 0 ]; then
newbright="$( cat /var/lib/pyra/keyboard-toggle-value)"
else
echo $curbright > /var/lib/pyra/keyboard-toggle-value
newbright=0
fi
echo $newbright > /sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/brightness
fi
fi
sudoers-file 100644 → 100755
File mode changed from 100644 to 100755
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment