From 3f4190e95a7554ab4f9d39af3f1824cdedc89ee9 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Sun, 11 May 2025 09:07:11 -0400 Subject: [PATCH] Backlight animation --- hyprland/.config/hypr/bind-framework.conf | 4 +- hyprland/.config/hypr/general.conf | 2 +- scripts/bin/system/backlight-ctl.sh | 52 +++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100755 scripts/bin/system/backlight-ctl.sh diff --git a/hyprland/.config/hypr/bind-framework.conf b/hyprland/.config/hypr/bind-framework.conf index 6aa2727..ec08d7c 100644 --- a/hyprland/.config/hypr/bind-framework.conf +++ b/hyprland/.config/hypr/bind-framework.conf @@ -1,7 +1,7 @@ # Screen brightness controls exec-once = light -N 1 -bind = ,XF86MonBrightnessUp, exec, light -A 5 # increase screen brightness -bind = ,XF86MonBrightnessDown, exec, light -U 5 # decrease screen brightness +bind = ,XF86MonBrightnessUp, exec, ~/bin/system/backlight-ctl.sh -i +bind = ,XF86MonBrightnessDown, exec, ~/bin/system/backlight-ctl.sh -d # Pulse Audio controls bind = ,XF86AudioRaiseVolume, exec, amixer set Master 3%+ #increase sound volume diff --git a/hyprland/.config/hypr/general.conf b/hyprland/.config/hypr/general.conf index 87d15e5..ef123b7 100644 --- a/hyprland/.config/hypr/general.conf +++ b/hyprland/.config/hypr/general.conf @@ -15,7 +15,7 @@ decoration { enabled = true size = 3 passes = 1 - } + } } animations { diff --git a/scripts/bin/system/backlight-ctl.sh b/scripts/bin/system/backlight-ctl.sh new file mode 100755 index 0000000..78e19f9 --- /dev/null +++ b/scripts/bin/system/backlight-ctl.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Print help info. +function print_help() { + echo 'Control the backlight brightness with animation.' + echo + echo '-i -- increase brightness' + echo '-d -- decrease brightness' +} + +# Increase backlight brightness. +function increase() { + run_animation 'light -A 0.1' +} + +# Decrease backlight brightness. +function decrease() { + run_animation 'light -U 0.1' +} + +# Run animation task. +function run_animation() { + local cmd="${1}" + i=0 + while [ $i -lt 50 ]; do + ${cmd} + sleep 0.01 + ((i = i + 1)); + done +} + + +# Check arguments +for i in "$@"; do + case $i in + -h|--help) + print_help + exit 0 + ;; + -i) + increase + ;; + -d) + decrease + ;; + *) + print_help + exit 1 + ;; + esac +done +