feat: store caffeinated status in a file to resume behaviour after reboot or similar

This commit is contained in:
Nydragon 2024-12-23 18:53:23 +01:00
parent 8b27f1f47d
commit 20d66304f8
Signed by: nydragon
SSH key fingerprint: SHA256:WcjW5NJPQ8Dx4uQDmoIlVPLWE27Od3fxoe0IUvuoPHE

View file

@ -7,9 +7,40 @@ Singleton {
id: inhibitor
property bool active: false
readonly property string caffeinatedLock: `${Quickshell.env("XDG_RUNTIME_DIR")}/qs-inhibitor`
function toggle() {
active = !active;
if (!active) {
create.running = true;
} else {
removing.running = true;
}
}
Process {
running: true
command: ["stat", inhibitor.caffeinatedLock]
onExited: (code, status) => {
inhibitor.active = !code;
}
}
Process {
id: create
running: false
command: ["touch", inhibitor.caffeinatedLock]
onExited: (code, status) => {
inhibitor.active = !code;
}
}
Process {
id: removing
running: false
command: ["rm", inhibitor.caffeinatedLock]
onExited: (code, status) => {
inhibitor.active = code != 0;
}
}
Process {