-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitors
executable file
·68 lines (57 loc) · 1.15 KB
/
monitors
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
61
62
63
64
65
66
67
68
#!/usr/bin/bash
source "$HOME/dotfiles/linux/variables.env"
get() {
last_monitor=$(echo $monitors | grep -o .$)
sudo ddcutil --bus=$last_monitor getvcp $feature | grep -oP 'current\svalue\s*=\s*\K\d+'
}
set() {
new_value="$1"
if [ "$new_value" -le -1 ] || [ "$new_value" -ge 101 ]; then
return 0
fi
IFS=$"\n"
while read -r line
do
sudo ddcutil --bus=$line setvcp $feature $new_value &> /dev/null &
done < <(echo $monitors)
}
show() {
value=$1
notify-send -a System \
-i "$FONT_AWESOME_PATH/light/display.svg" \
-h int:value:$value \
-h string:wired-tag:system \
"$feature_name"
}
case $1 in
brightness)
feature=10
feature_name=$1
;;
esac
monitors=$(sudo ddcutil detect | grep "I2C bus" | grep -o .$)
step=5
current=`get`
current=${current:-0}
case $2 in
if) echo $monitors | grep 1 ;;
get) echo "$current" ;;
set)
set $3
show $3
;;
inc)
new_value=$(($current + $step))
set $new_value
show $new_value
;;
dec)
new_value=$(($current - $step))
set $new_value
show $new_value
;;
reset)
set 0
show 0
;;
esac