-
Notifications
You must be signed in to change notification settings - Fork 0
/
kalyani.sh
35 lines (30 loc) · 1.2 KB
/
kalyani.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
printf "\nKalyani- a display brightness controller program\n"
printf "Use \`f\`,\`j\` (+- 0.1) and \`d\`,\`k\` (+-0.05) to control the brightness\nPress \`q\` when you're finished. \n\n"
display_name=$(xrandr | grep " connected" | cut -d" " -f1)
echo -n "Currently connected display: "
echo $display_name
i=0
# Fight me
while [ $i -le 0 ]
do
curr_brightness=$(xrandr --verbose --current | grep -i brightness | cut -d" " -f2)
echo -n "Current brightness level = "
echo $curr_brightness
read -n 1 -s input
if [ "$input" = "f" ]; then
x=`echo "$curr_brightness+0.1" | bc | awk '{ printf("%.1f\n",$1) '}`
xrandr --output "$display_name" --brightness "$x"
elif [ "$input" = "j" ]; then
x=`echo "$curr_brightness-0.1" | bc | awk '{ printf("%.1f\n",$1) '}`
xrandr --output "$display_name" --brightness "$x"
elif [ "$input" = "d" ]; then
x=`echo "$curr_brightness+0.05" | bc | awk '{ printf("%.3f\n",$1) '}`
xrandr --output "$display_name" --brightness "$x"
elif [ "$input" = "k" ]; then
x=`echo "$curr_brightness-0.05" | bc | awk '{ printf("%.3f\n",$1) '}`
xrandr --output "$display_name" --brightness "$x"
elif [ "$input" = "q" ]; then
printf "\nLooking great, man. Glad to be of service."
exit
fi
done