From 5c41160260900398b8f9440edf0c735946187e90 Mon Sep 17 00:00:00 2001 From: Don Williams Date: Sun, 5 Oct 2025 14:36:19 -0400 Subject: feat(hyprsunset): add Hyprsunset toggle script, SUPER+N keybind, and Waybar nightlight button across all layouts; include in status and vertical power groups --- config/hypr/scripts/Hyprsunset.sh | 77 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 config/hypr/scripts/Hyprsunset.sh (limited to 'config/hypr/scripts/Hyprsunset.sh') diff --git a/config/hypr/scripts/Hyprsunset.sh b/config/hypr/scripts/Hyprsunset.sh new file mode 100755 index 00000000..68e5fab8 --- /dev/null +++ b/config/hypr/scripts/Hyprsunset.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Hyprsunset toggle + Waybar status helper +# Phase 1: manual toggle only (no scheduling) +# Icons: +# - Off: bright sun +# - On: sunset icon if available, otherwise a blue sun +# +# Customize via env vars: +# HYPERSUNSET_TEMP default 4500 (K) +# HYPERSUNSET_ICON_MODE sunset|blue (default: sunset) + +STATE_FILE="$HOME/.cache/.hyprsunset_state" +TARGET_TEMP="${HYPERSUNSET_TEMP:-4500}" +ICON_MODE="${HYPERSUNSET_ICON_MODE:-sunset}" + +ensure_state() { + [[ -f "$STATE_FILE" ]] || echo "off" > "$STATE_FILE" +} + +# Render icons using pango markup to allow colorization +icon_off() { + # bright sun when not activated + printf "" +} + +icon_on() { + case "$ICON_MODE" in + sunset) + printf "" + ;; + blue) + printf "" + ;; + *) + printf "" + ;; + esac +} + +cmd_toggle() { + ensure_state + state="$(cat "$STATE_FILE" || echo off)" + if [[ "$state" == "on" ]]; then + if command -v hyprsunset >/dev/null 2>&1; then + hyprsunset -r || true + fi + echo off > "$STATE_FILE" + else + if command -v hyprsunset >/dev/null 2>&1; then + hyprsunset -t "$TARGET_TEMP" || true + fi + echo on > "$STATE_FILE" + fi +} + +cmd_status() { + ensure_state + state="$(cat "$STATE_FILE" || echo off)" + if [[ "$state" == "on" ]]; then + txt="$(icon_on)" + cls="on" + tip="Night light on @ ${TARGET_TEMP}K" + else + txt="$(icon_off)" + cls="off" + tip="Night light off" + fi + printf '{"text":"%s","class":"%s","tooltip":"%s"}\n' "$txt" "$cls" "$tip" +} + +case "${1:-}" in + toggle) cmd_toggle ;; + status) cmd_status ;; + *) echo "usage: $0 [toggle|status]" >&2; exit 2 ;; + esac -- cgit v1.2.3 From 4b2fb9ebeb2abaeb52f24ed4889801b36cbb2ba9 Mon Sep 17 00:00:00 2001 From: Don Williams Date: Sun, 5 Oct 2025 14:53:46 -0400 Subject: fix(hyprsunset): support hyprsunset v0.3.x (-i instead of -r), avoid CTM conflicts, run in background, process-based status --- config/hypr/scripts/Hyprsunset.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'config/hypr/scripts/Hyprsunset.sh') diff --git a/config/hypr/scripts/Hyprsunset.sh b/config/hypr/scripts/Hyprsunset.sh index 68e5fab8..0de19d44 100755 --- a/config/hypr/scripts/Hyprsunset.sh +++ b/config/hypr/scripts/Hyprsunset.sh @@ -42,14 +42,26 @@ icon_on() { cmd_toggle() { ensure_state state="$(cat "$STATE_FILE" || echo off)" + + # Always stop any running hyprsunset first to avoid CTM manager conflicts + if pgrep -x hyprsunset >/dev/null 2>&1; then + pkill -x hyprsunset || true + # give it a moment to release the CTM manager + sleep 0.2 + fi + if [[ "$state" == "on" ]]; then + # Turning OFF: set identity and exit if command -v hyprsunset >/dev/null 2>&1; then - hyprsunset -r || true + nohup hyprsunset -i >/dev/null 2>&1 & + # if hyprsunset persists, stop it shortly after applying identity + sleep 0.3 && pkill -x hyprsunset || true fi echo off > "$STATE_FILE" else + # Turning ON: start hyprsunset at target temp in background if command -v hyprsunset >/dev/null 2>&1; then - hyprsunset -t "$TARGET_TEMP" || true + nohup hyprsunset -t "$TARGET_TEMP" >/dev/null 2>&1 & fi echo on > "$STATE_FILE" fi @@ -57,8 +69,14 @@ cmd_toggle() { cmd_status() { ensure_state - state="$(cat "$STATE_FILE" || echo off)" - if [[ "$state" == "on" ]]; then + # Prefer live process detection; fall back to state file + if pgrep -x hyprsunset >/dev/null 2>&1; then + onoff="on" + else + onoff="$(cat "$STATE_FILE" || echo off)" + fi + + if [[ "$onoff" == "on" ]]; then txt="$(icon_on)" cls="on" tip="Night light on @ ${TARGET_TEMP}K" -- cgit v1.2.3 From d200f9134d5e6bbc558b8acaea64229ba7b420cb Mon Sep 17 00:00:00 2001 From: Don Williams Date: Sun, 5 Oct 2025 15:08:38 -0400 Subject: feat(hyprsunset): add libnotify messages on toggle; use plain glyph text; ensure nightlight button is visible in [TOP] Default Laptop; set escape=false for custom/nightlight --- config/hypr/scripts/Hyprsunset.sh | 15 +++++++++------ config/waybar/ModulesCustom | 3 ++- config/waybar/configs/[TOP] Default Laptop | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'config/hypr/scripts/Hyprsunset.sh') diff --git a/config/hypr/scripts/Hyprsunset.sh b/config/hypr/scripts/Hyprsunset.sh index 0de19d44..0372d720 100755 --- a/config/hypr/scripts/Hyprsunset.sh +++ b/config/hypr/scripts/Hyprsunset.sh @@ -21,20 +21,21 @@ ensure_state() { # Render icons using pango markup to allow colorization icon_off() { - # bright sun when not activated - printf "" + # bright sun when not activated (plain glyph; styling via Waybar CSS by class) + printf "" } icon_on() { case "$ICON_MODE" in sunset) - printf "" + # fallback to same glyph; color can be handled by CSS if desired + printf "" ;; blue) - printf "" + printf "" ;; *) - printf "" + printf "" ;; esac } @@ -50,7 +51,7 @@ cmd_toggle() { sleep 0.2 fi - if [[ "$state" == "on" ]]; then +if [[ "$state" == "on" ]]; then # Turning OFF: set identity and exit if command -v hyprsunset >/dev/null 2>&1; then nohup hyprsunset -i >/dev/null 2>&1 & @@ -58,12 +59,14 @@ cmd_toggle() { sleep 0.3 && pkill -x hyprsunset || true fi echo off > "$STATE_FILE" + notify-send -u low "Hyprsunset: Disabled" || true else # Turning ON: start hyprsunset at target temp in background if command -v hyprsunset >/dev/null 2>&1; then nohup hyprsunset -t "$TARGET_TEMP" >/dev/null 2>&1 & fi echo on > "$STATE_FILE" + notify-send -u low "Hyprsunset: Enabled" "${TARGET_TEMP}K" || true fi } diff --git a/config/waybar/ModulesCustom b/config/waybar/ModulesCustom index 1f4afa20..512ff751 100644 --- a/config/waybar/ModulesCustom +++ b/config/waybar/ModulesCustom @@ -112,7 +112,8 @@ "format": "{}", "on-click": "$HOME/.config/hypr/scripts/Hyprsunset.sh toggle", "tooltip": true, - "tooltip-format": "Night light toggle" + "tooltip-format": "Night light toggle", + "escape": false }, "custom/lock": { diff --git a/config/waybar/configs/[TOP] Default Laptop b/config/waybar/configs/[TOP] Default Laptop index b9722b89..0b264c6b 100644 --- a/config/waybar/configs/[TOP] Default Laptop +++ b/config/waybar/configs/[TOP] Default Laptop @@ -54,6 +54,7 @@ "custom/separator#line", "group/audio", "custom/separator#dot-line", + "custom/nightlight", "group/status", ], } \ No newline at end of file -- cgit v1.2.3 From eeb7d323e179e899bb21ae494b0052f0196362f9 Mon Sep 17 00:00:00 2001 From: Don Williams Date: Sun, 5 Oct 2025 15:23:05 -0400 Subject: fix(waybar/nightlight): use universal icons (☀/🌇) and explicit {text} format for JSON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/hypr/scripts/Hyprsunset.sh | 13 +++++++------ config/waybar/ModulesCustom | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'config/hypr/scripts/Hyprsunset.sh') diff --git a/config/hypr/scripts/Hyprsunset.sh b/config/hypr/scripts/Hyprsunset.sh index 0372d720..1e84bc66 100755 --- a/config/hypr/scripts/Hyprsunset.sh +++ b/config/hypr/scripts/Hyprsunset.sh @@ -21,21 +21,22 @@ ensure_state() { # Render icons using pango markup to allow colorization icon_off() { - # bright sun when not activated (plain glyph; styling via Waybar CSS by class) - printf "" + # universally available sun symbol + printf "☀" } icon_on() { case "$ICON_MODE" in sunset) - # fallback to same glyph; color can be handled by CSS if desired - printf "" + # sunset emoji (falls back to tofu if no emoji font) + printf "🌇" ;; blue) - printf "" + # no color in text; rely on CSS .on to style if desired + printf "☀" ;; *) - printf "" + printf "☀" ;; esac } diff --git a/config/waybar/ModulesCustom b/config/waybar/ModulesCustom index 512ff751..f4e95433 100644 --- a/config/waybar/ModulesCustom +++ b/config/waybar/ModulesCustom @@ -109,7 +109,7 @@ "return-type": "json", "exec": "$HOME/.config/hypr/scripts/Hyprsunset.sh status", "interval": 5, - "format": "{}", + "format": "{text}", "on-click": "$HOME/.config/hypr/scripts/Hyprsunset.sh toggle", "tooltip": true, "tooltip-format": "Night light toggle", -- cgit v1.2.3 From f24d5aed8e4362f42a022a52c16accbcb5b69c66 Mon Sep 17 00:00:00 2001 From: Don Williams Date: Sun, 5 Oct 2025 17:02:52 -0400 Subject: feat(nightlight/ui): enlarge icon via Pango markup (escape=false), reserve space (min-length) --- config/hypr/scripts/Hyprsunset.sh | 4 ++-- config/waybar/ModulesCustom | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'config/hypr/scripts/Hyprsunset.sh') diff --git a/config/hypr/scripts/Hyprsunset.sh b/config/hypr/scripts/Hyprsunset.sh index 1e84bc66..c7c4b395 100755 --- a/config/hypr/scripts/Hyprsunset.sh +++ b/config/hypr/scripts/Hyprsunset.sh @@ -81,11 +81,11 @@ cmd_status() { fi if [[ "$onoff" == "on" ]]; then - txt="$(icon_on)" + txt="$(icon_on)" cls="on" tip="Night light on @ ${TARGET_TEMP}K" else - txt="$(icon_off)" + txt="$(icon_off)" cls="off" tip="Night light off" fi diff --git a/config/waybar/ModulesCustom b/config/waybar/ModulesCustom index f4e95433..146ec275 100644 --- a/config/waybar/ModulesCustom +++ b/config/waybar/ModulesCustom @@ -108,8 +108,9 @@ "custom/nightlight": { "return-type": "json", "exec": "$HOME/.config/hypr/scripts/Hyprsunset.sh status", - "interval": 5, + "interval": 3, "format": "{text}", + "min-length": 2, "on-click": "$HOME/.config/hypr/scripts/Hyprsunset.sh toggle", "tooltip": true, "tooltip-format": "Night light toggle", -- cgit v1.2.3