mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-30 17:42:06 -04:00
fix(quickshell): restore night mode and OSD surfaces after resume (#2254)
This commit is contained in:
committed by
GitHub
parent
c6ed64b24e
commit
b87c36d29e
@@ -48,6 +48,9 @@ Singleton {
|
||||
signal loginctlStateChanged
|
||||
|
||||
property bool stateInitialized: false
|
||||
property string prepareForSleepSubscriptionId: ""
|
||||
property bool prepareForSleepSubscriptionPending: false
|
||||
property double lastResumeSignalTimestamp: 0
|
||||
|
||||
readonly property string socketPath: Quickshell.env("DMS_SOCKET")
|
||||
|
||||
@@ -463,10 +466,13 @@ Singleton {
|
||||
function onConnectionStateChanged() {
|
||||
if (DMSService.isConnected) {
|
||||
checkDMSCapabilities();
|
||||
} else {
|
||||
clearPrepareForSleepSubscriptionState();
|
||||
}
|
||||
}
|
||||
|
||||
function onCapabilitiesReceived() {
|
||||
checkDMSCapabilities();
|
||||
syncSleepInhibitor();
|
||||
}
|
||||
}
|
||||
@@ -478,6 +484,13 @@ Singleton {
|
||||
function onCapabilitiesChanged() {
|
||||
checkDMSCapabilities();
|
||||
}
|
||||
|
||||
function onDbusSignalReceived(subscriptionId, data) {
|
||||
if (subscriptionId !== prepareForSleepSubscriptionId) {
|
||||
return;
|
||||
}
|
||||
handlePrepareForSleepSignal(data);
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
@@ -539,6 +552,61 @@ Singleton {
|
||||
loginctlAvailable = false;
|
||||
console.log("SessionService: loginctl capability not available in DMS");
|
||||
}
|
||||
|
||||
if (DMSService.capabilities.includes("dbus")) {
|
||||
ensurePrepareForSleepSubscription();
|
||||
} else {
|
||||
clearPrepareForSleepSubscriptionState();
|
||||
}
|
||||
}
|
||||
|
||||
function clearPrepareForSleepSubscriptionState() {
|
||||
prepareForSleepSubscriptionId = "";
|
||||
prepareForSleepSubscriptionPending = false;
|
||||
}
|
||||
|
||||
function ensurePrepareForSleepSubscription() {
|
||||
if (!DMSService.isConnected || !DMSService.capabilities.includes("dbus")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prepareForSleepSubscriptionId || prepareForSleepSubscriptionPending) {
|
||||
return;
|
||||
}
|
||||
|
||||
prepareForSleepSubscriptionPending = true;
|
||||
DMSService.dbusSubscribe("system", "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep", response => {
|
||||
prepareForSleepSubscriptionPending = false;
|
||||
|
||||
if (response.error) {
|
||||
console.warn("SessionService: Failed to subscribe to PrepareForSleep:", response.error);
|
||||
return;
|
||||
}
|
||||
|
||||
prepareForSleepSubscriptionId = response.result?.subscriptionId || "";
|
||||
});
|
||||
}
|
||||
|
||||
function emitSessionResumedOnce() {
|
||||
const now = Date.now();
|
||||
if ((now - lastResumeSignalTimestamp) < 1000) {
|
||||
return;
|
||||
}
|
||||
lastResumeSignalTimestamp = now;
|
||||
sessionResumed();
|
||||
}
|
||||
|
||||
function handlePrepareForSleepSignal(data) {
|
||||
if (!data?.body || data.body.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const wasSleeping = preparingForSleep;
|
||||
preparingForSleep = data.body[0] === true;
|
||||
|
||||
if (wasSleeping && !preparingForSleep) {
|
||||
emitSessionResumedOnce();
|
||||
}
|
||||
}
|
||||
|
||||
function getLoginctlState() {
|
||||
@@ -604,7 +672,7 @@ Singleton {
|
||||
}
|
||||
|
||||
if (wasSleeping && !preparingForSleep) {
|
||||
sessionResumed();
|
||||
emitSessionResumedOnce();
|
||||
}
|
||||
|
||||
loginctlStateChanged();
|
||||
|
||||
Reference in New Issue
Block a user