1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-12 16:38:28 -04:00

power profile: hide when ppd not available

fixes #3031
This commit is contained in:
bbedward
2026-08-11 10:31:46 -04:00
parent 2f27eab949
commit 373a3d3136
+23 -1
View File
@@ -4,14 +4,27 @@ pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Services.UPower
import qs.Services
Singleton {
id: root
property int currentProfile: -1
property int previousProfile: -1
property bool daemonRunning: true
readonly property bool available: typeof PowerProfiles !== "undefined"
readonly property bool available: typeof PowerProfiles !== "undefined" && daemonRunning
function checkDaemon() {
if (!DMSService.isConnected || !DMSService.capabilities.includes("dbus"))
return;
DMSService.dbusCall("system", "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameHasOwner", ["org.freedesktop.UPower.PowerProfiles"], response => {
if (response.error || !response.result)
return;
root.daemonRunning = response.result.values?.[0] === true;
});
}
readonly property var availableProfiles: {
if (!available)
@@ -78,6 +91,7 @@ Singleton {
function onProfileChanged() {
if (typeof PowerProfiles !== "undefined") {
root.daemonRunning = true;
root.previousProfile = root.currentProfile;
root.currentProfile = PowerProfiles.profile;
if (root.previousProfile !== -1) {
@@ -87,6 +101,14 @@ Singleton {
}
}
Connections {
target: DMSService
function onCapabilitiesReceived() {
root.checkDaemon();
}
}
Component.onCompleted: {
if (typeof PowerProfiles !== "undefined") {
root.currentProfile = PowerProfiles.profile;