blob: 5c455ef17d5b7b5ba898fa3ed50f7d0d6fab2be0 (
plain) (
blame)
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
69
70
71
72
73
|
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# Script for Monitor backlights (if supported) using brightnessctl
iDIR="$HOME/.config/swaync/icons"
notification_timeout=1000
# Get brightness
get_backlight() {
brightnessctl -m | cut -d, -f4 | sed 's/%//'
}
# Get icons
get_icon() {
current=$(get_backlight)
if [ "$current" -le "20" ]; then
icon="$iDIR/brightness-20.png"
elif [ "$current" -le "40" ]; then
icon="$iDIR/brightness-40.png"
elif [ "$current" -le "60" ]; then
icon="$iDIR/brightness-60.png"
elif [ "$current" -le "80" ]; then
icon="$iDIR/brightness-80.png"
else
icon="$iDIR/brightness-100.png"
fi
}
# Notify
notify_user() {
notify-send -e -h string:x-canonical-private-synchronous:brightness_notif -h int:value:$current -u low -i "$icon" "Brightness : $current%"
}
# Change brightness
change_backlight() {
local current_brightness
current_brightness=$(get_backlight)
# Calculate new brightness
if [[ "$1" == "+5%" ]]; then
new_brightness=$((current_brightness + 5))
elif [[ "$1" == "5%-" ]]; then
new_brightness=$((current_brightness - 5))
fi
# Ensure new brightness is within valid range
if (( new_brightness < 0 )); then
new_brightness=0
elif (( new_brightness > 100 )); then
new_brightness=100
fi
brightnessctl set "${new_brightness}%"
get_icon
current=$new_brightness
notify_user
}
# Execute accordingly
case "$1" in
"--get")
get_backlight
;;
"--inc")
change_backlight "+5%"
;;
"--dec")
change_backlight "5%-"
;;
*)
get_backlight
;;
esac
|