-
Notifications
You must be signed in to change notification settings - Fork 0
/
fun.sh
executable file
·62 lines (47 loc) · 1.47 KB
/
fun.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/zsh
# get the filepath to backlight_brightness
backlight_path="/sys/class/backlight/"$(ls /sys/class/backlight/)"/brightness"
maxbright_path="/sys/class/backlight/"$(ls /sys/class/backlight/)"/max_brightness"
max_brightness=$(cat $maxbright_path)
actul_brightness=$(cat $backlight_path)
echo $max_brightness
echo $actul_brightness
function fun(){
delta=$((max_brightness / 20))
set_brightness=$(($delta * $1))
echo $set_brightness > $backlight_path
}
function display(){
clear
char=" "
str=[
for ((i=0 ; i<20 ; i++)){
((i<$1)) && char="# "
str+=$char
char=" "
}
str+=]
echo $str
}
zmodload zsh/net/socket
zsocket test.socket
fd=$REPLY
level=$((($actul_brightness * 20 ) / $max_brightness))
percent=$(($level * 5))
echo $percent | dialog --title "BackLight Controller" --gauge "----------------------Level:$level--------------------------" 8 60
#dialog --title "installation" "installation" 10 30 $percent
op=0
while [[ $op != 'q' ]]; do
read -k 1 op
if [[ $op == 'h' ]]; then
[[ $level != '1' ]] && level=$(($level-1))
fun $level
fi
if [[ $op == 'l' ]]; then
[[ $level != "20" ]] && level=$(($level+1))
fun $level
fi
percent=$(($level * 5))
echo $percent | dialog --title "BackLight Controller" --gauge "----------------------Level:$level--------------------------" 8 60
#dialog --title "installation pro" "installation" 10 30 $percent --keep-window
done