-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrightness
More file actions
66 lines (58 loc) · 2.05 KB
/
brightness
File metadata and controls
66 lines (58 loc) · 2.05 KB
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
#!/usr/bin/env bash
## Copyright (C) 2020-2021 Aditya Shakya <adi1090x@gmail.com>
## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3
## Script To Manage Brightness For Archcraft
# Graphics card
CARD=`ls /sys/class/backlight | head -n 1`
# Get brightness
get_backlight() {
if [[ "$CARD" == *"intel_"* ]]; then
BNESS=`xbacklight -get`
LIGHT=${BNESS%.*}
else
LIGHT=$(print "%.0f\n" `light -G`)
fi
echo "${LIGHT}%"
}
# Get icons
get_icon() {
backlight="${get_backlight}"
current="${backlight%%%}"
if [[ ("$current" -ge "0") && ("$current" -le "20") ]]; then
icon='/usr/share/archcraft/icons/dunst/brightness-20.png'
elif [[ ("$current" -ge "20") && ("$current" -le "40") ]]; then
icon='/usr/share/archcraft/icons/dunst/brightness-40.png'
elif [[ ("$current" -ge "40") && ("$current" -le "60") ]]; then
icon='/usr/share/archcraft/icons/dunst/brightness-60.png'
elif [[ ("$current" -ge "60") && ("$current" -le "80") ]]; then
icon='/usr/share/archcraft/icons/dunst/brightness-80.png'
elif [[ ("$current" -ge "80") && ("$current" -le "100") ]]; then
icon='/usr/share/archcraft/icons/dunst/brightness-100.png'
fi
}
# Increase brightness
inc_backlight() {
if [[ "$CARD" == *"intel_"* ]]; then
xbacklight -inc 10 && get_icon && dunstify -u low --replace=69 -i "$icon" "Brightness : $(get_backlight)"
else
light -A 5 && get_icon && dunstify -u low --replace=69 -i "$icon" "Brightness : $(get_backlight)"
fi
}
# Decrease brightness
dec_backlight() {
if [[ "$CARD" == *"intel_"* ]]; then
xbacklight -dec 10 && get_icon && dunstify -u low --replace=69 -i "$icon" "Brightness : (get_backlight)"
else
light -U 5 && get_icon && dunstify -u low --replace=69 -i "$icon" "Brightness : $(get_backlight)"
fi
}
# Execute accordingly
if [[ "$1" == "--get" ]]; then
get_backlight
elif [[ "$1" == "--inc" ]]; then
inc_backlight
elif [[ "$1" == "--dec" ]]; then
dec_backlight
else
get_backlight
fi