1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00
Files
DankMaterialShell/quickshell/Services/PowerProfileWatcher.qml

37 lines
944 B
QML

pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Services.UPower
Singleton {
id: root
property int currentProfile: -1
property int previousProfile: -1
signal profileChanged(int profile)
Connections {
target: typeof PowerProfiles !== "undefined" ? PowerProfiles : null
function onProfileChanged() {
if (typeof PowerProfiles !== "undefined") {
root.previousProfile = root.currentProfile;
root.currentProfile = PowerProfiles.profile;
if (root.previousProfile !== -1) {
root.profileChanged(root.currentProfile);
}
}
}
}
Component.onCompleted: {
if (typeof PowerProfiles !== "undefined") {
root.currentProfile = PowerProfiles.profile;
root.previousProfile = PowerProfiles.profile;
}
}
}