diff options
| author | krolxon <krolyxon@tutanota.com> | 2025-08-25 15:41:08 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2025-08-25 15:41:08 +0530 |
| commit | a81ab033ec5ac0cdbdddfc31f242aee7cb5aee4e (patch) | |
| tree | 2e4f8155dcc468c214749982a752884985186ad6 /.config/hypr/scripts | |
| parent | b4ff09016c4d75c8accc4d8fff51c536bed10ec9 (diff) | |
hyprland: add hypr_brightness script
This script uses ddcutil and allows you to also control the brightness
of external displays.
It changes the brightness of the display that you are currently focused
in.
Diffstat (limited to '.config/hypr/scripts')
| -rwxr-xr-x | .config/hypr/scripts/hypr_brightness.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/.config/hypr/scripts/hypr_brightness.sh b/.config/hypr/scripts/hypr_brightness.sh new file mode 100755 index 0000000..2ba9d98 --- /dev/null +++ b/.config/hypr/scripts/hypr_brightness.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env sh +# Source: https://github.com/albertnis/hypr-brightness +# Install ddcutil, and then enable access to i2c for your user + +# sudo gpasswd -a $USER i2c +# sudo modprobe i2c-dev +# echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf + +set +e + +usage="Usage: $0 [+] or [-]" + +if [ "$#" -ne 1 ]; then + echo "No direction parameter provided" + echo "$usage" + exit 1 +fi + +arg="$1" + +if [ "$arg" == "help" ] || [ "$arg" == "--help" ] || [ "$arg" == "-h" ]; then + echo "$usage" + exit 0 +fi + +if [ "$arg" != "+" ] && [ "$arg" != "-" ]; then + echo "Direction parameter must be '+' or '-'" + echo $usage + exit 1 +fi + +direction=$arg + +monitor_data=$(hyprctl monitors -j) +focused_name=$(echo $monitor_data | jq -r '.[] | select(.focused == true) | .name') + +if [ "$focused_name" == "eDP-1" ]; then + if [ "$direction" == "-" ]; then + brightnessctl -e4 -n2 set 5%- + else + brightnessctl -e4 -n2 set 5%+ + fi +else + focused_id=$(echo $monitor_data | jq -r '.[] | select(.focused == true) | .id') + ddcutil --enable-dynamic-sleep --display=$focused_id setvcp 10 $direction 15 +fi |
