omarchy/bin/omarchy-status-daemon
Alan Sikora 318a6e23cf
Add status indicator cluster for waybar (#570)
* feat: Add notification status indicator to waybar

Adds a visual indicator in the waybar to show when notifications are silenced (do-not-disturb mode).

- Shows a red dot when notifications are disabled
- Shows a dimmed dot when notifications are enabled
- Clicking the indicator toggles do-not-disturb mode
- Syncs with the existing SUPER+CTRL+, keyboard shortcut

This provides immediate visual feedback about notification status, making it easier for users to know when they've silenced notifications.

* feat: Convert to unified status cluster that only shows active states

- Only displays indicators when states are actually active
- Supports multiple status types: DND, night light, screen recording, idle lock
- Uses distinct symbols: • for DND, ◐ for night light, ● for recording, ◯ for idle lock
- Completely hides module when no states are active (no visual clutter)
- Extensible design for future status indicators
- Improved performance with better error handling

* Implement lightweight hybrid status monitoring

* Enhance notification status cluster with modular design

* Add waybar configuration for status cluster

* Add recording click handler and fix process detection

- Add wl-screenrec detection for non-nvidia systems
- Add click handler to start/stop recording
- Fix idle lock toggle functionality

* minor alignment tweaks

* improved recording detection to be more specific

* Rely on Omarchy bin in PATH and lower interval to feel more snappy

* Seperate out screencording stop so it doesn't start when trying to stop OBS

* Add migration to add the status notifications

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
2025-08-23 08:26:31 +02:00

65 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Status indicator daemon for waybar
# Calls individual status scripts and caches results
STATE_DIR="/tmp/omarchy-status"
DAEMON_PID_FILE="$STATE_DIR/daemon.pid"
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
mkdir -p "$STATE_DIR"
# Update all status files by calling individual scripts
update_all_status_files() {
"$SCRIPT_DIR/omarchy-status-dnd" > "$STATE_DIR/dnd"
"$SCRIPT_DIR/omarchy-status-nightlight" > "$STATE_DIR/nightlight"
"$SCRIPT_DIR/omarchy-status-recording" > "$STATE_DIR/recording"
"$SCRIPT_DIR/omarchy-status-idle" > "$STATE_DIR/idle"
}
# Generate hash for change detection
get_status_hash() {
echo "$(pgrep -c "mako|hyprsunset|wl-screenrec|wf-recorder|obs|hypridle" 2>/dev/null)$(makoctl mode 2>/dev/null | grep -c 'do-not-disturb')$(hyprctl hyprsunset temperature 2>/dev/null)"
}
# Start background monitoring daemon
start_daemon() {
if [ -f "$DAEMON_PID_FILE" ] && kill -0 $(cat "$DAEMON_PID_FILE") 2>/dev/null; then
return 0
fi
{
last_hash=""
while true; do
current_hash=$(get_status_hash)
if [ "$current_hash" != "$last_hash" ]; then
update_all_status_files
last_hash="$current_hash"
fi
sleep 0.5
done
} &
echo $! > "$DAEMON_PID_FILE"
}
# Main execution
MODULE="$1"
if [ -z "$MODULE" ]; then
echo "Usage: $0 [dnd|nightlight|recording|idle]"
exit 1
fi
start_daemon
# Return cached status for requested module
if [ -f "$STATE_DIR/$MODULE" ]; then
cat "$STATE_DIR/$MODULE"
else
update_all_status_files
cat "$STATE_DIR/$MODULE" 2>/dev/null || echo '{"text": "", "tooltip": "", "class": "hidden"}'
fi