auroraa81ab03
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.
+51 −4
2 files changed
- M .config/hypr/hyprland.conf +5 −4
- A .config/hypr/scripts/hypr_brightness.sh +46 −0
| @@ -4,7 +4,7 @@ autogenerated = 0 | |||
| 4 | 4 | ### MY PROGRAMS ### | |
| 5 | 5 | ################### | |
| 6 | 6 | $terminal = footclient | |
| 7 | − | $menu = rofi -show run | |
| 7 | + | $menu = fuzzel | |
| 8 | 8 | $browser = zen-browser | |
| 9 | 9 | ||
| 10 | 10 | ||
| @@ -215,7 +215,7 @@ bind = $mainMod SHIFT, P, pseudo, # dwindle | |||
| 215 | 215 | bind = $mainMod, J, togglesplit, # dwindle | |
| 216 | 216 | binde = $mainMod, tab, cyclenext, prev | |
| 217 | 217 | bind = $mainMod, b, exec, killall waybar || waybar | |
| 218 | − | bind = $mainMod, grave, exec, rofiunicode | |
| 218 | + | bind = $mainMod, grave, exec, fuzzelunicode | |
| 219 | 219 | bind = $mainMod, escape, exec, sysact | |
| 220 | 220 | ||
| 221 | 221 | # Applications | |
| @@ -283,8 +283,9 @@ bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ | |||
| 283 | 283 | bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- | |
| 284 | 284 | bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle | |
| 285 | 285 | bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle | |
| 286 | − | bindel = ,XF86MonBrightnessUp, exec, brightnessctl -e4 -n2 set 5%+ | |
| 287 | − | bindel = ,XF86MonBrightnessDown, exec, brightnessctl -e4 -n2 set 5%- | |
| 286 | + | bindel = , XF86MonBrightnessDown, exec, ~/.config/hypr/scripts/hypr_brightness.sh - | |
| 287 | + | bindel = , XF86MonBrightnessUp, exec, ~/.config/hypr/scripts/hypr_brightness.sh + | |
| 288 | + | ||
| 288 | 289 | ||
| 289 | 290 | # Requires playerctl | |
| 290 | 291 | bindl = , XF86AudioNext, exec, playerctl next | |
| @@ -0,0 +1,46 @@ | |||
| 1 | + | #!/usr/bin/env sh | |
| 2 | + | # Source: https://github.com/albertnis/hypr-brightness | |
| 3 | + | # Install ddcutil, and then enable access to i2c for your user | |
| 4 | + | ||
| 5 | + | # sudo gpasswd -a $USER i2c | |
| 6 | + | # sudo modprobe i2c-dev | |
| 7 | + | # echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf | |
| 8 | + | ||
| 9 | + | set +e | |
| 10 | + | ||
| 11 | + | usage="Usage: $0 [+] or [-]" | |
| 12 | + | ||
| 13 | + | if [ "$#" -ne 1 ]; then | |
| 14 | + | echo "No direction parameter provided" | |
| 15 | + | echo "$usage" | |
| 16 | + | exit 1 | |
| 17 | + | fi | |
| 18 | + | ||
| 19 | + | arg="$1" | |
| 20 | + | ||
| 21 | + | if [ "$arg" == "help" ] || [ "$arg" == "--help" ] || [ "$arg" == "-h" ]; then | |
| 22 | + | echo "$usage" | |
| 23 | + | exit 0 | |
| 24 | + | fi | |
| 25 | + | ||
| 26 | + | if [ "$arg" != "+" ] && [ "$arg" != "-" ]; then | |
| 27 | + | echo "Direction parameter must be '+' or '-'" | |
| 28 | + | echo $usage | |
| 29 | + | exit 1 | |
| 30 | + | fi | |
| 31 | + | ||
| 32 | + | direction=$arg | |
| 33 | + | ||
| 34 | + | monitor_data=$(hyprctl monitors -j) | |
| 35 | + | focused_name=$(echo $monitor_data | jq -r '.[] | select(.focused == true) | .name') | |
| 36 | + | ||
| 37 | + | if [ "$focused_name" == "eDP-1" ]; then | |
| 38 | + | if [ "$direction" == "-" ]; then | |
| 39 | + | brightnessctl -e4 -n2 set 5%- | |
| 40 | + | else | |
| 41 | + | brightnessctl -e4 -n2 set 5%+ | |
| 42 | + | fi | |
| 43 | + | else | |
| 44 | + | focused_id=$(echo $monitor_data | jq -r '.[] | select(.focused == true) | .id') | |
| 45 | + | ddcutil --enable-dynamic-sleep --display=$focused_id setvcp 10 $direction 15 | |
| 46 | + | fi | |