diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
| commit | 28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch) | |
| tree | 85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/monitorbright | |
| parent | 8470ff001befcfd0f626dea69a9e76d43aee0511 (diff) | |
updates
Diffstat (limited to 'debian/.local/bin/monitorbright')
| -rwxr-xr-x | debian/.local/bin/monitorbright | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/debian/.local/bin/monitorbright b/debian/.local/bin/monitorbright new file mode 100755 index 0000000..2de2e5d --- /dev/null +++ b/debian/.local/bin/monitorbright @@ -0,0 +1,24 @@ +#!/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" + current_brightness=$(echo "$new_brightness * 100" | bc -l) + else + current_brightness=$(echo "$current_brightness * 100" | bc -l) + fi + printf "🪟%.0f%%\n" "$current_brightness" + ;; +esac |
