feat: use Quickshell-internal idle inhibitor

This was a pain to set up properly...
This commit is contained in:
Kiana Sheibani 2025-11-11 00:33:44 -05:00
parent e82bdbc9a2
commit c9e7e7022b
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
4 changed files with 17 additions and 32 deletions

View file

@ -1,47 +1,28 @@
pragma Singleton
import qs.util
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Wayland
import Quickshell.Services.Pipewire
Singleton {
id: root
property alias inhibit: inhibitor.running
property bool inhibitPipewire
property bool inhibit: false
property bool inhibitPipewire: true
function toggleInhibitPipewire() {
root.inhibitPipewire = !root.inhibitPipewire;
pipewireInhibitor.running = true;
}
// Idle Inhibitor
Process {
IdleInhibitor {
id: inhibitor
command: ["wayland-idle-inhibitor"]
enabled: root.inhibit ||
(root.inhibitPipewire &&
!!Pipewire.nodes.values.find(node => node.isSink && node.isStream))
window: null
}
// Idle Inhibit on Pipewire
readonly property string pipewireInhibitorService: "wayland-pipewire-idle-inhibit.service"
Timer {
id: pipewireInhibitorTimer
running: true
repeat: true
triggeredOnStart: true
onTriggered: pipewireInhibitorCheck.running = true
}
Process {
id: pipewireInhibitorCheck
command: ["systemctl", "status", "--user", root.pipewireInhibitorService]
onExited: (code, _) => root.inhibitPipewire = (code === 0)
}
Process {
id: pipewireInhibitor
command: ["systemctl", root.inhibitPipewire ? "start" : "stop", "--user", root.pipewireInhibitorService]
onTriggered: inhibitor.window = States.screens.values().next()?.value?.window
}
}