feat(presence-detect): tint caffeine eww widget hot pink while presence holds the lock
Add presence-status.sh reporting true only when the daemon (not a manual caffeine toggle) owns the shared idle lock, via the existing OWNED_FLAG. Wire it into all three eww bars: the caffeine button gains a .caffeine-presence class → the #E40046 Active accent used elsewhere, so camera-driven auto-awake is visually distinct from a manual session. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>main
parent
defa69faab
commit
dc9cf6d830
|
|
@ -78,6 +78,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;
|
||||
}
|
||||
|
||||
menuitem {
|
||||
border: solid;
|
||||
border-width: 3px;
|
||||
|
|
|
|||
|
|
@ -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" ? "☕" : ""}))
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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" ? "☕" : ""}))
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,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;
|
||||
}
|
||||
|
||||
menuitem {
|
||||
border: solid;
|
||||
border-width: 3px;
|
||||
|
|
|
|||
|
|
@ -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" ? "☕" : ""}))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue