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 { Toggle {
label.text: qsTr("Inhibit While Playing Audio") label.text: qsTr("Inhibit While Playing Audio")
checked: Idle.inhibitPipewire checked: Idle.inhibitPipewire
toggle.onToggled: Idle.toggleInhibitPipewire() toggle.onToggled: Idle.inhibitPipewire = !Idle.inhibitPipewire
} }
component Toggle: RowLayout { component Toggle: RowLayout {

View file

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

View file

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

View file

@ -1,47 +1,28 @@
pragma Singleton pragma Singleton
import qs.util
import QtQuick import QtQuick
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Wayland
import Quickshell.Services.Pipewire
Singleton { Singleton {
id: root id: root
property alias inhibit: inhibitor.running property bool inhibit: false
property bool inhibitPipewire property bool inhibitPipewire: true
function toggleInhibitPipewire() { IdleInhibitor {
root.inhibitPipewire = !root.inhibitPipewire;
pipewireInhibitor.running = true;
}
// Idle Inhibitor
Process {
id: inhibitor 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 { Timer {
id: pipewireInhibitorTimer
running: true running: true
repeat: true repeat: true
triggeredOnStart: true onTriggered: inhibitor.window = States.screens.values().next()?.value?.window
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]
} }
} }