mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-12 16:38:28 -04:00
@@ -4,14 +4,27 @@ pragma ComponentBehavior: Bound
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
|
import qs.Services
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property int currentProfile: -1
|
property int currentProfile: -1
|
||||||
property int previousProfile: -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: {
|
readonly property var availableProfiles: {
|
||||||
if (!available)
|
if (!available)
|
||||||
@@ -78,6 +91,7 @@ Singleton {
|
|||||||
|
|
||||||
function onProfileChanged() {
|
function onProfileChanged() {
|
||||||
if (typeof PowerProfiles !== "undefined") {
|
if (typeof PowerProfiles !== "undefined") {
|
||||||
|
root.daemonRunning = true;
|
||||||
root.previousProfile = root.currentProfile;
|
root.previousProfile = root.currentProfile;
|
||||||
root.currentProfile = PowerProfiles.profile;
|
root.currentProfile = PowerProfiles.profile;
|
||||||
if (root.previousProfile !== -1) {
|
if (root.previousProfile !== -1) {
|
||||||
@@ -87,6 +101,14 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: DMSService
|
||||||
|
|
||||||
|
function onCapabilitiesReceived() {
|
||||||
|
root.checkDaemon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (typeof PowerProfiles !== "undefined") {
|
if (typeof PowerProfiles !== "undefined") {
|
||||||
root.currentProfile = PowerProfiles.profile;
|
root.currentProfile = PowerProfiles.profile;
|
||||||
|
|||||||
Reference in New Issue
Block a user