commit 2fdc371
hovercats
·
2023-01-14 13:02:26 +0000 UTC
parent 86a6c59
rewrite bri. thanks wael
1 files changed,
+5,
-27
M
bri
M
bri
+5,
-27
1@@ -1,33 +1,11 @@
2 #!/bin/sh -e
3-
4 # A simple script to change screen brightness.
5
6-# Path to brightness file, which holds value of current brightness
7-# This path may be different across systems, change it accordingly
8-# You will also need read/write access to this file.
9-# Permissions on this file does however not persist across reboots, so a boot
10-# hook is neccessary to set appropriate permissions upon boot.
11-BRI_FILE='/sys/class/backlight/amdgpu_bl0/brightness'
12-CURR_BRI=$(cat "$BRI_FILE")
13-
14-increase () {
15- echo "$CURR_BRI" + 10 | bc > NEW_BRI
16- cat NEW_BRI > "$BRI_FILE"
17- rm -r NEW_BRI
18-}
19-
20-decrease () {
21- echo "$CURR_BRI" - 10 | bc > NEW_BRI
22- cat NEW_BRI > "$BRI_FILE"
23- rm -r NEW_BRI
24-}
25-
26-help () {
27- printf "Useage:\n\nUse 'd' or 'i' to decrease or increase screen brightness"
28-}
29+file='/sys/class/backlight/amdgpu_bl0/brightness'
30+read -r brightness < "$file"
31
32 case $1 in
33- i) increase ;;
34- d) decrease ;;
35- *) help ;;
36+ d) printf "%s\n" "$((brightness - 5))" > "$file" ;;
37+ i) printf "%s\n" "$((brightness + 5))" > "$file" ;;
38+ *) printf "%s\n" "usage: ${0##*/} d|i" ;;
39 esac