Stay Awake: fix state detection, rename, notify on toggle
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy:summary=Toggle hypridle idle locking
|
# omarchy:summary=Toggle hypridle so the system either idles normally or stays awake
|
||||||
|
|
||||||
if pgrep -x hypridle >/dev/null; then
|
if pgrep -x hypridle >/dev/null; then
|
||||||
pkill -x hypridle
|
pkill -x hypridle
|
||||||
|
omarchy-notification-send -g "" "Staying awake" "Idle behavior disabled"
|
||||||
else
|
else
|
||||||
uwsm-app -- hypridle >/dev/null 2>&1 &
|
uwsm-app -- hypridle >/dev/null 2>&1 &
|
||||||
|
omarchy-notification-send -g "" "Idle behavior on" "System can now sleep / lock on idle"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
omarchy-shell-ipc --if-running bar refreshIndicators >/dev/null 2>&1 || true
|
omarchy-shell-ipc --if-running bar refreshIndicators >/dev/null 2>&1 || true
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ Item {
|
|||||||
"notificationCenter": { displayName: "Notification center", description: "Recent notifications + DND", category: "Status", allowMultiple: false },
|
"notificationCenter": { displayName: "Notification center", description: "Recent notifications + DND", category: "Status", allowMultiple: false },
|
||||||
"systemStats": { displayName: "System stats", description: "CPU icon — hover for graphs, click to open btop", category: "System", allowMultiple: false },
|
"systemStats": { displayName: "System stats", description: "CPU icon — hover for graphs, click to open btop", category: "System", allowMultiple: false },
|
||||||
"weatherFlyout": { displayName: "Weather", description: "Weather pill with detail popup", category: "Info", allowMultiple: false, settingsForm: "weatherSettings" },
|
"weatherFlyout": { displayName: "Weather", description: "Weather pill with detail popup", category: "Info", allowMultiple: false, settingsForm: "weatherSettings" },
|
||||||
"idleInhibitor": { displayName: "Keep awake", description: "Toggle idle inhibitor", category: "System", allowMultiple: false },
|
"idleInhibitor": { displayName: "Stay awake", description: "Toggle whether the system can idle", category: "System", allowMultiple: false },
|
||||||
"microphone": { displayName: "Microphone", description: "Mic input state and mute toggle", category: "Audio", allowMultiple: false },
|
"microphone": { displayName: "Microphone", description: "Mic input state and mute toggle", category: "Audio", allowMultiple: false },
|
||||||
"activeWindow": { displayName: "Active window", description: "Title of the focused window", category: "Compositor", allowMultiple: false },
|
"activeWindow": { displayName: "Active window", description: "Title of the focused window", category: "Compositor", allowMultiple: false },
|
||||||
"keyboardLayout": { displayName: "Keyboard layout", description: "Current xkb layout, click cycles", category: "Compositor", allowMultiple: false },
|
"keyboardLayout": { displayName: "Keyboard layout", description: "Current xkb layout, click cycles", category: "Compositor", allowMultiple: false },
|
||||||
|
|||||||
@@ -27,12 +27,11 @@ Item {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: statusProc
|
id: statusProc
|
||||||
command: ["bash", "-lc", "if pgrep -x hyprlock >/dev/null 2>&1; then echo locked; elif pgrep -f 'systemd-inhibit' >/dev/null 2>&1; then echo inhibited; elif [[ -f /tmp/omarchy-idle-off ]]; then echo off; else echo idle; fi"]
|
command: ["bash", "-lc", "pgrep -x hypridle >/dev/null 2>&1 && echo running || echo stopped"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
waitForEnd: true
|
waitForEnd: true
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
var state = String(text || "").trim()
|
root.active = String(text || "").trim() === "stopped"
|
||||||
root.active = state === "inhibited" || state === "off"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +58,7 @@ Item {
|
|||||||
bar: root.bar
|
bar: root.bar
|
||||||
text: root.icon
|
text: root.icon
|
||||||
active: root.active
|
active: root.active
|
||||||
tooltipText: root.active ? "Idle inhibited — click to allow sleep" : "System can idle — click to keep awake"
|
tooltipText: root.active ? "Staying awake — click to allow idle" : "Can idle — click to stay awake"
|
||||||
onPressed: function() { root.toggle() }
|
onPressed: function() { root.toggle() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user