From 98c0e6b56cf084f18946cbf3af26212ebc58b03f Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Thu, 26 Jun 2025 02:26:33 +0200 Subject: [PATCH] hypr: migrate wayland-generic gamma control to hyprsunset --- dot-config/hypr/hyprland.conf | 12 ++--- dot-config/hypr/scripts/hyprsunset.sh | 67 +++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 6 deletions(-) create mode 100755 dot-config/hypr/scripts/hyprsunset.sh diff --git a/dot-config/hypr/hyprland.conf b/dot-config/hypr/hyprland.conf index e3cf609d..e9bf0e97 100644 --- a/dot-config/hypr/hyprland.conf +++ b/dot-config/hypr/hyprland.conf @@ -20,7 +20,6 @@ xwayland { # See https://wiki.hyprland.org/Configuring/Keywords/ for more exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP -exec-once = sunsetr # exec-shutdown = setenv WAYLAND_DISPLAY= XDG_SESSION_TYPE= XDG_CURRENT_DESKTOP= # Execute your favorite apps at launch @@ -28,6 +27,7 @@ exec-once = ~/.config/hypr/scripts/startup.sh exec-once = hypridle exec-once = hyprpm reload exec-once = hyprpaper +exec-once = hyprsunset exec-once = flatpak run ch.threema.threema-desktop # For all categories, see https://wiki.hyprland.org/Configuring/Variables/ @@ -67,7 +67,7 @@ general { # col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg col.active_border = 0xfa$base0C 0xff$base0B 45deg col.inactive_border = 0xfa$base02 - col.nogroup_border_active = 0xff$base0E + col.nogroup_border_active = 0xff$base09 col.nogroup_border = 0xfa$base02 layout = dwindle @@ -168,7 +168,7 @@ device { group { merge_groups_on_drag = 0 insert_after_current = 1 - col.border_locked_active = 0xfa$base0E + col.border_locked_active = 0xfa$base09 col.border_locked_inactive = 0xfa$base02 col.border_active = 0xEE$base0C col.border_inactive = 0xfa$base02 @@ -187,10 +187,10 @@ group { text_color = 0xFF$base00 gradients = true scrolling = false - col.locked_active = 0xfa$base0E 0x8a$base0E 45deg + col.locked_active = 0xfa$base09 0x8a$base09 45deg col.locked_inactive = 0xfa$base04 0x8a$base04 45deg - col.active = 0xfa$base0C 0xfa$base0D 45deg - col.inactive = 0xfa$base04 0xaa$base04 45deg + col.active = 0xfa$base0C 0x8a$base0C 45deg + col.inactive = 0xfa$base04 0x8a$base04 45deg rounding = 4 gradient_rounding = 4 gradient_round_only_edges = true diff --git a/dot-config/hypr/scripts/hyprsunset.sh b/dot-config/hypr/scripts/hyprsunset.sh new file mode 100755 index 00000000..385c8a77 --- /dev/null +++ b/dot-config/hypr/scripts/hyprsunset.sh @@ -0,0 +1,67 @@ +#!/bin/bash +CMD=$1 +DELTA=$2 +TOGGLE=$3 +if [ -z "$CMD" ]; then + echo "Set or get gamma and color temperature through hyprsunset IPC socket" + echo "Usage: sunset.sh [+-][value] [toggle]" + exit 1 +fi +if [[ ! -z "$TOGGLE" ]]; then + CUR=$(hyprctl hyprsunset $CMD) + FMT=$(LC_NUMERIC="en_US.UTF-8" printf "%.0f" $CUR 2>/dev/null) + if [ "$FMT" = "$DELTA" ]; then + if [ "$CMD" = "gamma" ]; then + DELTA=100 + else + DELTA=6500 + fi + fi +fi +[ "$CMD" = "gamma" ] && LEN=3 || LEN=4 +if [[ ! -z "$DELTA" ]]; then + # rate limit and queue commands to workaround nvidia freezing on ctm spam + flock /tmp/sunset.lock sleep 0.1 + # tell waybar to update after a change + pkill -SIGRTMIN+$LEN waybar +fi +if NUM=$(hyprctl hyprsunset $CMD $DELTA); then + if FMT=$(LC_NUMERIC="en_US.UTF-8" printf "%$LEN.0f" $NUM 2>/dev/null); then + echo "$FMT" + fi +fi + + +# #!/bin/bash +# CMD="$1" +# DELTA="$2" +# TOGGLE="$3" +# if [ -z "$CMD" ]; then +# echo "Set or get gamma and color temperature through hyprsunset IPC socket" +# echo "Usage: sunset.sh [+-][value] [toggle]" +# exit 1 +# fi +# if [[ -n "$TOGGLE" ]]; then +# CUR=$(hyprctl hyprsunset "$CMD") +# FMT=$(LC_NUMERIC="en_US.UTF-8" printf "%.0f" "$CUR" 2>/dev/null) +# if [ "$FMT" = "$DELTA" ]; then +# if [ "$CMD" = "gamma" ]; then +# DELTA=100 +# else +# DELTA=6500 +# fi +# fi +# fi +# [ "$CMD" = "gamma" ] && LEN=3 || LEN=4 +# if [[ -n "$DELTA" ]]; then +# # rate limit and queue commands to workaround nvidia freezing on ctm spam +# flock /tmp/sunset.lock sleep 0.1 +# # tell waybar to update after a change +# pkill -SIGRTMIN+"$LEN" waybar +# fi +# if NUM=$(hyprctl hyprsunset "$CMD" "$DELTA"); then +# if FMT=$(LC_NUMERIC="en_US.UTF-8" printf "%$LEN.0f" "$NUM" 2>/dev/null); then +# echo "$FMT" +# fi +# fi + -- 2.51.2