summaryrefslogtreecommitdiff
path: root/ar/.local/bin/monitorbright
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-03-27 09:14:57 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-03-27 09:14:57 +0900
commit4fedb93eb5eda39fd3024dc9ce712b8aae269a41 (patch)
tree18891d3417255fb839c34a1849687134bac12db7 /ar/.local/bin/monitorbright
parentf60c21b17c0de2f0cf05f65dec23857d2947fb55 (diff)
modified bin/monitorbright, modified statusbar/sb-brightness
Diffstat (limited to 'ar/.local/bin/monitorbright')
-rwxr-xr-xar/.local/bin/monitorbright39
1 files changed, 21 insertions, 18 deletions
diff --git a/ar/.local/bin/monitorbright b/ar/.local/bin/monitorbright
index db2bcf3..6e69614 100755
--- a/ar/.local/bin/monitorbright
+++ b/ar/.local/bin/monitorbright
@@ -1,20 +1,23 @@
#!/bin/sh
-monitor=$(xrandr --query | grep -i '\sconnected' | grep '[0-9]x[0-9]' | grep -i 'primary' | cut -d ' ' -f1)
-[ -z "$monitor" ] && monitor=$(xrandr --query | grep -i '\sconnected' | grep '[0-9]x[0-9]' | cut -d ' ' -f1)
-case "$monitor" in
-*DP* | *HDMI*)
- current_brightness=$(xrandr --verbose | grep -i "^$monitor connected" -A5 | grep -i "Brightness:" | cut -d ' ' -f2)
- [ -z "$current_brightness" ] && exit 1
- if [ "$#" -eq 2 ]; then
- scale_change=$(echo "$2 / 100" | bc -l)
- case "$1" in
- "-inc") new_brightness=$(echo "$current_brightness + $scale_change" | bc -l) ;;
- "-dec") new_brightness=$(echo "$current_brightness - $scale_change" | bc -l) ;;
- *) echo "Invalid argument $1. Use -inc or -dec." && exit 1 ;;
- esac
- new_brightness=$(echo "if ($new_brightness > 1) 1 else if ($new_brightness < 0) 0 else $new_brightness" | bc -l)
- xrandr --output "$monitor" --brightness "$new_brightness"
- fi
- ;;
-esac
+xrandr_verbose=$(xrandr --verbose)
+monitors=$(echo "$xrandr_verbose" | grep -i '\sconnected' | grep '[0-9]x[0-9]' | cut -d ' ' -f1)
+
+for monitor in $monitors; do
+ case "$monitor" in
+ *DP* | *DisplayPort* | *HDMI*)
+ current_brightness=$(echo "$xrandr_verbose" | grep -i "^$monitor connected" -A5 | grep -i "Brightness:" | cut -d ' ' -f2)
+ [ -z "$current_brightness" ] && continue
+ if [ "$#" -eq 2 ]; then
+ scale_change=$(echo "$2 / 100" | bc -l)
+ case "$1" in
+ "-inc") new_brightness=$(echo "$current_brightness + $scale_change" | bc -l) ;;
+ "-dec") new_brightness=$(echo "$current_brightness - $scale_change" | bc -l) ;;
+ *) echo "Invalid argument $1. Use -inc or -dec." && exit 1 ;;
+ esac
+ new_brightness=$(echo "if ($new_brightness > 1) 1 else if ($new_brightness < 0) 0 else $new_brightness" | bc -l)
+ xrandr --output "$monitor" --brightness "$new_brightness"
+ fi
+ ;;
+ esac
+done