-
Notifications
You must be signed in to change notification settings - Fork 0
/
brightness_loop.sh
44 lines (33 loc) · 904 Bytes
/
brightness_loop.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
36
37
38
39
40
41
42
43
44
#!/bin/sh
# Bash Script to set a brightness loop (just for fun).
# Doesn't work for Multiple Displays.
# Author : wh0am1
# GitHub : https://github.com/wh0th3h3llam1
function brightness_loop()
{
lowest_value=5
highest_value=99
current_value=$highest_value
direction=-1
printf "Enter Delay in Seconds (Default Value is 0.01 Sec): "
read delay
# Check if user input is null.
# If null, then it will assign 1 as default to delay variable.
if [ -z $delay ]
then
delay=0.01
fi
while(true);
do
if [[ $current_value -lt $lowest_value || $current_value -gt $highest_value ]];
then
direction=$( expr $direction \* -1 )
fi
current_value=$( expr $current_value + $direction )
level="$( echo "scale=2; $current_value/100" | bc )"
xrandr --output $display --brightness $level
sleep $delay
done
}
display="$( xrandr | grep -w "connected" | cut -f1 -d " " ) "
brightness_loop