-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path,brightness
executable file
·56 lines (49 loc) · 1.57 KB
/
,brightness
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
#!/usr/bin/env bash
if ! (type xbacklight >/dev/null); then
notify-send -u critical 'xbacklight command not found. Run `sudo apt install xbacklight`'
exit 2
fi
intel_backlight="/sys/class/backlight/intel_backlight"
if ! [[ -d "$intel_backlight" ]]; then
notify-send -u critical "intel_backlight not found"
exit 2
fi
# Increase/descrease brightness
if [[ "$1" == "up" ]]; then
xbacklight -inc 10
elif [[ "$1" == "down" ]]; then
xbacklight -dec 10
fi
# Popup notification for brightness
brightness="$(xbacklight -get 2>&1)"
if (($?)); then
# Example:
# https://askubuntu.com/questions/715306/xbacklight-no-outputs-have-backlight-property-no-sys-class-backlight-folder
# sudo find /sys/ -type f -iname '*brightness*'
# sudo ln -s /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight /sys/class/backlight
notify-send -u critical "xbacklight: $brightness"
# TODO: Check for this file: /etc/X11/xorg.conf
# https://askubuntu.com/questions/715306/xbacklight-no-outputs-have-backlight-property-no-sys-class-backlight-folder
exit 2
fi
# If the screen turns completely off, set birghtness to 1%
if (("${brightness%%.*}" == 0)); then
xbacklight -set 1
fi
# Display brightness notification
brightness_icon="🔆"
bar_color="#6090b0"
dunstify \
--timeout=1000 \
--replace=2593 \
--urgency=normal \
"$brightness_icon $brightness%" \
--hints="int:value:$brightness" \
--hints="string:hlcolor:$bar_color"
exit
# Use notify-send to print brightness
notify-send \
-t 400 \
-u normal \
-h string:x-canonical-private-synchronous:brightness \
"Brightness: ${brightness%%.*}%"