feat(hypr): implement display and keyboard backlight dimming
This commit is contained in:
@@ -6,8 +6,20 @@ general {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listener {
|
listener {
|
||||||
timeout = 300 # 5min
|
timeout = 290
|
||||||
on-timeout = loginctl lock-session # lock screen when timeout has passed
|
on-timeout = ~/.config/hypr/scripts/dim-display.sh dim
|
||||||
|
on-resume = ~/.config/hypr/scripts/dim-display.sh restore
|
||||||
|
}
|
||||||
|
|
||||||
|
listener {
|
||||||
|
timeout = 300
|
||||||
|
on-timeout = loginctl lock-session
|
||||||
|
}
|
||||||
|
|
||||||
|
listener {
|
||||||
|
timeout = 300
|
||||||
|
on-timeout = ~/.config/hypr/scripts/dim-keyboard.sh dim
|
||||||
|
on-resume = ~/.config/hypr/scripts/dim-keyboard.sh restore
|
||||||
}
|
}
|
||||||
|
|
||||||
listener {
|
listener {
|
||||||
|
|||||||
35
hypr/scripts/dim-display.sh
Executable file
35
hypr/scripts/dim-display.sh
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCREEN_DEVICE="amdgpu_bl1"
|
||||||
|
|
||||||
|
STATE_DIR="${XDG_RUNTIME_DIR:-/tmp}/hypridle"
|
||||||
|
SCREEN_STATE_FILE="$STATE_DIR/screen"
|
||||||
|
|
||||||
|
mkdir -p "$STATE_DIR"
|
||||||
|
|
||||||
|
save_current() {
|
||||||
|
brightnessctl -d "$SCREEN_DEVICE" g >"$SCREEN_STATE_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
dim() {
|
||||||
|
save_current
|
||||||
|
brightnessctl -d "$SCREEN_DEVICE" set 10%
|
||||||
|
}
|
||||||
|
|
||||||
|
restore() {
|
||||||
|
[[ -f "$SCREEN_STATE_FILE" ]] && brightnessctl -d "$SCREEN_DEVICE" s "$(cat "$SCREEN_STATE_FILE")"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
|
dim)
|
||||||
|
dim
|
||||||
|
;;
|
||||||
|
restore)
|
||||||
|
restore
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {dim|restore}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
35
hypr/scripts/dim-keyboard.sh
Executable file
35
hypr/scripts/dim-keyboard.sh
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
KBD_DEVICE="chromeos::kbd_backlight"
|
||||||
|
|
||||||
|
STATE_DIR="${XDG_RUNTIME_DIR:-/tmp}/hypridle"
|
||||||
|
KBD_STATE_FILE="$STATE_DIR/kbd"
|
||||||
|
|
||||||
|
mkdir -p "$STATE_DIR"
|
||||||
|
|
||||||
|
save_current() {
|
||||||
|
brightnessctl -d "$KBD_DEVICE" g >"$KBD_STATE_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
dim() {
|
||||||
|
save_current
|
||||||
|
brightnessctl -d "$KBD_DEVICE" set 0
|
||||||
|
}
|
||||||
|
|
||||||
|
restore() {
|
||||||
|
[[ -f "$KBD_STATE_FILE" ]] && brightnessctl -d "$KBD_DEVICE" s "$(cat "$KBD_STATE_FILE")"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
|
dim)
|
||||||
|
dim
|
||||||
|
;;
|
||||||
|
restore)
|
||||||
|
restore
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {dim|restore}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Reference in New Issue
Block a user