diff --git a/desktopenvs/hyprlua/eww-nobattery/eww.scss b/desktopenvs/hyprlua/eww-nobattery/eww.scss index 3e0afad..dc6ce50 100644 --- a/desktopenvs/hyprlua/eww-nobattery/eww.scss +++ b/desktopenvs/hyprlua/eww-nobattery/eww.scss @@ -75,7 +75,13 @@ tooltip { .workspace-active { color: #E40046; - + +} + +// caffeine widget while the presence-detect daemon holds the idle lock: +// tint it the Active Hot Pink accent used for highlights everywhere else. +.caffeine-presence { + color: #E40046; } menuitem { diff --git a/desktopenvs/hyprlua/eww-nobattery/eww.yuck b/desktopenvs/hyprlua/eww-nobattery/eww.yuck index 83a80e5..302118f 100644 --- a/desktopenvs/hyprlua/eww-nobattery/eww.yuck +++ b/desktopenvs/hyprlua/eww-nobattery/eww.yuck @@ -118,9 +118,15 @@ (defpoll caffeine-active :interval "2s" "~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine-status.sh") +; presence-active poll — true only when the presence-detect daemon (not a manual +; caffeine toggle) is holding the idle lock, i.e. the camera currently sees you. +(defpoll presence-active :interval "2s" + "~/Dotfiles/desktopenvs/hyprlua/scripts/presence-status.sh") + (defwidget caffeine [] - (button :class "music" + (button :class {presence-active == "true" ? "music caffeine-presence" : "music"} :onclick "~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine.sh" - :tooltip {caffeine-active == "true" ? "Caffeine: ON" : "Caffeine: OFF"} + :tooltip {presence-active == "true" ? "Caffeine: ON (presence)" + : caffeine-active == "true" ? "Caffeine: ON" : "Caffeine: OFF"} {caffeine-active == "true" ? "☕" : "󰅺"})) diff --git a/desktopenvs/hyprlua/eww-touch/eww.scss b/desktopenvs/hyprlua/eww-touch/eww.scss index eaba4a7..88fc01f 100644 --- a/desktopenvs/hyprlua/eww-touch/eww.scss +++ b/desktopenvs/hyprlua/eww-touch/eww.scss @@ -83,6 +83,12 @@ tooltip { } +// caffeine widget while the presence-detect daemon holds the idle lock: +// tint it the Active Hot Pink accent used for highlights everywhere else. +.caffeine-presence { + color: #E40046; +} + // astal-menu launcher button — accent-coloured icon, highlight on hover .menu-launcher { color: #E40046; diff --git a/desktopenvs/hyprlua/eww-touch/eww.yuck b/desktopenvs/hyprlua/eww-touch/eww.yuck index 2cf248b..6c2415d 100644 --- a/desktopenvs/hyprlua/eww-touch/eww.yuck +++ b/desktopenvs/hyprlua/eww-touch/eww.yuck @@ -164,9 +164,15 @@ (defpoll caffeine-active :interval "2s" "~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine-status.sh") +; presence-active poll — true only when the presence-detect daemon (not a manual +; caffeine toggle) is holding the idle lock, i.e. the camera currently sees you. +(defpoll presence-active :interval "2s" + "~/Dotfiles/desktopenvs/hyprlua/scripts/presence-status.sh") + (defwidget caffeine [] - (button :class "music" + (button :class {presence-active == "true" ? "music caffeine-presence" : "music"} :onclick "~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine.sh" - :tooltip {caffeine-active == "true" ? "Caffeine: ON" : "Caffeine: OFF"} + :tooltip {presence-active == "true" ? "Caffeine: ON (presence)" + : caffeine-active == "true" ? "Caffeine: ON" : "Caffeine: OFF"} {caffeine-active == "true" ? "☕" : "󰅺"})) diff --git a/desktopenvs/hyprlua/eww/eww.scss b/desktopenvs/hyprlua/eww/eww.scss index 50959a2..5d381da 100644 --- a/desktopenvs/hyprlua/eww/eww.scss +++ b/desktopenvs/hyprlua/eww/eww.scss @@ -75,7 +75,13 @@ tooltip { .workspace-active { color: #E40046; - + +} + +// caffeine widget while the presence-detect daemon holds the idle lock: +// tint it the Active Hot Pink accent used for highlights everywhere else. +.caffeine-presence { + color: #E40046; } menuitem { diff --git a/desktopenvs/hyprlua/eww/eww.yuck b/desktopenvs/hyprlua/eww/eww.yuck index e5a7ffc..260bb40 100644 --- a/desktopenvs/hyprlua/eww/eww.yuck +++ b/desktopenvs/hyprlua/eww/eww.yuck @@ -206,11 +206,20 @@ (defpoll caffeine-active :interval "2s" "~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine-status.sh") +; presence-active poll — true only when the presence-detect daemon (not a manual +; caffeine toggle) is holding the idle lock, i.e. the camera currently sees you. +; Used to tint the caffeine widget in the Active Hot Pink accent. +(defpoll presence-active :interval "2s" + "~/Dotfiles/desktopenvs/hyprlua/scripts/presence-status.sh") + ; caffeine widget — a button that toggles the caffeine idle-inhibit lock. ; ☕ = caffeine is ON (screen won't sleep), 󰅺 = caffeine is OFF (normal idle). -; Tooltip shows the current state for clarity. +; When presence detection is the reason the lock is held, the widget also turns +; the Active Hot Pink accent (.caffeine-presence) so auto-awake is distinct from +; a manual caffeine session. Tooltip shows the current state for clarity. (defwidget caffeine [] - (button :class "music" + (button :class {presence-active == "true" ? "music caffeine-presence" : "music"} :onclick "~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine.sh" - :tooltip {caffeine-active == "true" ? "Caffeine: ON" : "Caffeine: OFF"} + :tooltip {presence-active == "true" ? "Caffeine: ON (presence)" + : caffeine-active == "true" ? "Caffeine: ON" : "Caffeine: OFF"} {caffeine-active == "true" ? "☕" : "󰅺"})) diff --git a/desktopenvs/hyprlua/scripts/presence-status.sh b/desktopenvs/hyprlua/scripts/presence-status.sh new file mode 100755 index 0000000..0c60489 --- /dev/null +++ b/desktopenvs/hyprlua/scripts/presence-status.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Reports whether the *presence-detect daemon* is currently holding the idle +# inhibitor (i.e. the camera saw motion and is auto-keeping the screen awake), +# as opposed to a manual caffeine toggle. +# +# The lock is shared with caffeine.sh, so PID_FILE alone can't tell the two +# sources apart. OWNED_FLAG is touched only by presence-detect.sh when it starts +# the inhibitor and cleared by both a manual caffeine toggle and the daemon's +# own release — so "PID alive AND OWNED_FLAG present" uniquely means the daemon +# owns the lock right now. +# +# Prints "true" when presence-detect owns the lock, else "false". Used by the +# Eww caffeine widget to highlight itself in the Active Hot Pink accent. +PID_FILE="/tmp/caffeine-inhibit.pid" +OWNED_FLAG="/tmp/presence-inhibit-owned" + +if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null && [[ -f "$OWNED_FLAG" ]]; then + echo "true" +else + echo "false" +fi