Krolyxon
Commit a81ab03

Branches

Refs →

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.
Author
krolxon
Date
2025-08-25 15:41 +0530
Parent
b4ff090
Commit
a81ab033ec5ac0cdbdddfc31f242aee7cb5aee4e

+51 −4

2 files changed

  1. M .config/hypr/hyprland.conf +5 −4
  2. A .config/hypr/scripts/hypr_brightness.sh +46 −0
M .config/hypr/hyprland.conf View
@@ -4,7 +4,7 @@ autogenerated = 0
44 ### MY PROGRAMS ###
55 ###################
66 $terminal = footclient
7−$menu = rofi -show run
7+$menu = fuzzel
88 $browser = zen-browser
99
1010
@@ -215,7 +215,7 @@ bind = $mainMod SHIFT, P, pseudo, # dwindle
215215 bind = $mainMod, J, togglesplit, # dwindle
216216 binde = $mainMod, tab, cyclenext, prev
217217 bind = $mainMod, b, exec, killall waybar || waybar
218−bind = $mainMod, grave, exec, rofiunicode
218+bind = $mainMod, grave, exec, fuzzelunicode
219219 bind = $mainMod, escape, exec, sysact
220220
221221 # Applications
@@ -283,8 +283,9 @@ bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@
283283 bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
284284 bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
285285 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+
288289
289290 # Requires playerctl
290291 bindl = , XF86AudioNext, exec, playerctl next
A .config/hypr/scripts/hypr_brightness.sh View
@@ -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