Files
mxandClaude Opus 5.5 0dcf37346c Add a Caffeine inhibitor, app stream volumes and vertical bar sliders
CaffeineService holds a systemd-inhibit idle/sleep lock while active.
AudioService lists app playback streams and tracks their volume only
while a view holds a Demand on it. GlassBarSlider fills from the bottom
when vertical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 20:52:14 +02:00

38 lines
1.1 KiB
QML

pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
// Keeps the session awake while on: holds a systemd idle and sleep inhibitor,
// which hypridle and logind both honour. Off again after a shell restart.
Singleton {
id: root
property bool active: false
property var command: ["systemd-inhibit", "--what=idle:sleep", "--who=glassMxrph", "--why=Caffeine", "--mode=block", "sleep", "infinity"]
readonly property bool running: inhibitor.running
function toggle() {
active = !active;
return true;
}
Process {
id: inhibitor
command: root.command
running: root.active
// The inhibitor exiting on its own (logind refused it) turns the tile off.
onRunningChanged: if (!running && root.active)
root.active = false
}
IpcHandler {
target: "caffeine"
function toggle(): bool {
return root.toggle();
}
function status(): string {
return JSON.stringify({
active: root.active,
running: inhibitor.running
});
}
}
}