-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbacklight
executable file
·59 lines (47 loc) · 1.55 KB
/
backlight
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
#!/bin/env bash
function _help() {
echo "Usage: $(basename "$0") COMMAND VALUE [image]
Simple script to manage cases in which when actual brightness value is set in a value between 0 and 10
the it seams to be multiplied with no reason leading to 10% be equals to 100% and 11% (the next step) is effectively dark.
COMMANDS:
up Increase brightness level
down Decrease brightness level
VALUE:
This value is parsed by brightnessctl, possible values are integers or perentage
Example:
$(basename "$0") up 10
$(basename "$0") down 10%
IMAGE:
This represent the full path to the image to use in notifications, this is optional.
By default the first element containing the name \"brightness.svg\" enumerating /usr/share/icons/ is selected.
Example:
$(basename "$0") up 10 ~/.icons/my-brightness-icon.svg"
}
function notify() {
notify-send -t 1000 -h string:x-canonical-private-synchronous:sys-notify -u low \
-i "$IMAGE" \
"Backlight $ACTION" "Brightness : $(brightnessctl g)"
}
function handle() {
local ACTION="$1"
local QUANTITY="$2"
local IMAGE=${3:-$(find /usr/share/icons/ -type f -iname '*brightness*.svg' | head -1)}
case "$ACTION" in
up)
brightnessctl -q set +"$QUANTITY"
notify
;;
down)
if [[ $(brightnessctl g) -ge 15 ]]; then
brightnessctl -q set "$QUANTITY"-
notify
else
:
fi
;;
*)
_help
;;
esac
}
handle "$@"