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

@ -23,7 +23,7 @@ ColumnLayout {
Toggle {
label.text: qsTr("Inhibit While Playing Audio")
checked: Idle.inhibitPipewire
toggle.onToggled: Idle.toggleInhibitPipewire()
toggle.onToggled: Idle.inhibitPipewire = !Idle.inhibitPipewire
}
component Toggle: RowLayout {

View file

@ -30,6 +30,7 @@ Variants {
UIState {
id: uiState
window: window
screen: scope.modelData
}

View file

@ -8,12 +8,15 @@ import Quickshell.Hyprland
Scope {
id: root
required property QtObject window
required property ShellScreen screen
property alias uiState: uiState
PersistentProperties {
id: uiState
reloadableId: `uiState-${QsWindow.window.screen.name}`
reloadableId: `uiState-${root.screen.name}`
readonly property QtObject window: root.window
// Open panels
property bool dashboard

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
}
}