mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-02 02:22: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
@@ -346,12 +346,11 @@ Singleton {
|
|||||||
function onLoginctlEvent(event) {
|
function onLoginctlEvent(event) {
|
||||||
if (!SessionData.themeModeAutoEnabled)
|
if (!SessionData.themeModeAutoEnabled)
|
||||||
return;
|
return;
|
||||||
if (event.event === "unlock" || event.event === "resume") {
|
if (typeof SettingsData !== "undefined" && SettingsData.loginctlLockIntegration)
|
||||||
if (!themeAutoBackendAvailable()) {
|
|
||||||
root.evaluateThemeMode();
|
|
||||||
return;
|
return;
|
||||||
}
|
const eventType = String(event?.type || event?.event || "").toLowerCase();
|
||||||
DMSService.sendRequest("theme.auto.trigger", {});
|
if (eventType === "unlock") {
|
||||||
|
root.triggerThemeAutomationRefresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,6 +413,27 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: SessionService
|
||||||
|
enabled: typeof SessionService !== "undefined" && typeof SessionData !== "undefined" && SessionData.themeModeAutoEnabled
|
||||||
|
|
||||||
|
function onSessionUnlocked() {
|
||||||
|
root.triggerThemeAutomationRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSessionResumed() {
|
||||||
|
root.triggerThemeAutomationRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function triggerThemeAutomationRefresh() {
|
||||||
|
if (!themeAutoBackendAvailable()) {
|
||||||
|
root.evaluateThemeMode();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DMSService.sendRequest("theme.auto.trigger", {});
|
||||||
|
}
|
||||||
|
|
||||||
function applyGreeterTheme(themeName) {
|
function applyGreeterTheme(themeName) {
|
||||||
switchTheme(themeName, false, false);
|
switchTheme(themeName, false, false);
|
||||||
if (themeName === dynamic && dynamicColorsFileView.path) {
|
if (themeName === dynamic && dynamicColorsFileView.path) {
|
||||||
|
|||||||
@@ -27,6 +27,15 @@ import qs.Services
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property bool osdSurfacesLoaded: true
|
||||||
|
property int pendingOsdResumeReloads: 0
|
||||||
|
|
||||||
|
function recreateOsdSurfaces() {
|
||||||
|
OSDManager.currentOSDsByScreen = ({});
|
||||||
|
osdSurfacesLoaded = false;
|
||||||
|
osdSurfaceReloadTimer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
Instantiator {
|
Instantiator {
|
||||||
id: daemonPluginInstantiator
|
id: daemonPluginInstantiator
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
@@ -232,6 +241,32 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: osdResumeRecreateTimer
|
||||||
|
interval: 400
|
||||||
|
repeat: false
|
||||||
|
onTriggered: {
|
||||||
|
root.recreateOsdSurfaces();
|
||||||
|
|
||||||
|
if (root.pendingOsdResumeReloads > 1) {
|
||||||
|
root.pendingOsdResumeReloads--;
|
||||||
|
interval = 1400;
|
||||||
|
restart();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
root.pendingOsdResumeReloads = 0;
|
||||||
|
interval = 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: osdSurfaceReloadTimer
|
||||||
|
interval: 120
|
||||||
|
repeat: false
|
||||||
|
onTriggered: root.osdSurfacesLoaded = true
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
dockRecreateDebounce.start();
|
dockRecreateDebounce.start();
|
||||||
// Force PolkitService singleton to initialize
|
// Force PolkitService singleton to initialize
|
||||||
@@ -749,6 +784,16 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: SessionService
|
||||||
|
|
||||||
|
function onSessionResumed() {
|
||||||
|
root.pendingOsdResumeReloads = 2;
|
||||||
|
osdResumeRecreateTimer.interval = 400;
|
||||||
|
osdResumeRecreateTimer.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DankColorPickerModal {
|
DankColorPickerModal {
|
||||||
id: colorPickerModal
|
id: colorPickerModal
|
||||||
|
|
||||||
@@ -923,6 +968,13 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: osdSurfacesLoader
|
||||||
|
active: root.osdSurfacesLoaded
|
||||||
|
asynchronous: false
|
||||||
|
|
||||||
|
sourceComponent: Component {
|
||||||
|
Item {
|
||||||
Variants {
|
Variants {
|
||||||
model: SettingsData.getFilteredScreens("osd")
|
model: SettingsData.getFilteredScreens("osd")
|
||||||
|
|
||||||
@@ -971,12 +1023,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
|
||||||
id: powerProfileWatcherLoader
|
|
||||||
active: SettingsData.osdPowerProfileEnabled
|
|
||||||
source: "Services/PowerProfileWatcher.qml"
|
|
||||||
}
|
|
||||||
|
|
||||||
Variants {
|
Variants {
|
||||||
model: SettingsData.osdPowerProfileEnabled ? SettingsData.getFilteredScreens("osd") : []
|
model: SettingsData.osdPowerProfileEnabled ? SettingsData.getFilteredScreens("osd") : []
|
||||||
|
|
||||||
@@ -1000,6 +1046,15 @@ Item {
|
|||||||
modelData: item
|
modelData: item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: powerProfileWatcherLoader
|
||||||
|
active: SettingsData.osdPowerProfileEnabled
|
||||||
|
source: "Services/PowerProfileWatcher.qml"
|
||||||
|
}
|
||||||
|
|
||||||
LazyLoader {
|
LazyLoader {
|
||||||
id: hyprlandOverviewLoader
|
id: hyprlandOverviewLoader
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ Singleton {
|
|||||||
property bool nightModeEnabled: false
|
property bool nightModeEnabled: false
|
||||||
property bool automationAvailable: false
|
property bool automationAvailable: false
|
||||||
property bool gammaControlAvailable: false
|
property bool gammaControlAvailable: false
|
||||||
|
property int resumeRecoveryAttempt: 0
|
||||||
|
|
||||||
property var gammaState: ({})
|
property var gammaState: ({})
|
||||||
property int gammaCurrentTemp: gammaState?.currentTemp ?? 0
|
property int gammaCurrentTemp: gammaState?.currentTemp ?? 0
|
||||||
@@ -672,6 +673,15 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function runResumeRecoveryPass() {
|
||||||
|
checkGammaControlAvailability();
|
||||||
|
rescanDevices();
|
||||||
|
|
||||||
|
if (nightModeEnabled) {
|
||||||
|
evaluateNightMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkGammaControlAvailability() {
|
function checkGammaControlAvailability() {
|
||||||
if (!DMSService.isConnected) {
|
if (!DMSService.isConnected) {
|
||||||
return;
|
return;
|
||||||
@@ -730,6 +740,26 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: resumeRecoveryTimer
|
||||||
|
interval: 400
|
||||||
|
repeat: false
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
runResumeRecoveryPass();
|
||||||
|
resumeRecoveryAttempt++;
|
||||||
|
|
||||||
|
if (resumeRecoveryAttempt < 3) {
|
||||||
|
interval = resumeRecoveryAttempt === 1 ? 1400 : 2600;
|
||||||
|
restart();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resumeRecoveryAttempt = 0;
|
||||||
|
interval = 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function rescanDevices() {
|
function rescanDevices() {
|
||||||
if (!DMSService.isConnected) {
|
if (!DMSService.isConnected) {
|
||||||
return;
|
return;
|
||||||
@@ -815,16 +845,20 @@ Singleton {
|
|||||||
updateSingleDevice(device);
|
updateSingleDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLoginctlEvent(event) {
|
function onGammaStateUpdate(data) {
|
||||||
if (event.event === "unlock" || event.event === "resume") {
|
root.gammaState = data;
|
||||||
suppressOsd = true;
|
|
||||||
osdSuppressTimer.restart();
|
|
||||||
evaluateNightMode();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onGammaStateUpdate(data) {
|
Connections {
|
||||||
root.gammaState = data;
|
target: SessionService
|
||||||
|
|
||||||
|
function onSessionResumed() {
|
||||||
|
suppressOsd = true;
|
||||||
|
osdSuppressTimer.restart();
|
||||||
|
resumeRecoveryAttempt = 0;
|
||||||
|
resumeRecoveryTimer.interval = 400;
|
||||||
|
resumeRecoveryTimer.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ Singleton {
|
|||||||
signal loginctlStateChanged
|
signal loginctlStateChanged
|
||||||
|
|
||||||
property bool stateInitialized: false
|
property bool stateInitialized: false
|
||||||
|
property string prepareForSleepSubscriptionId: ""
|
||||||
|
property bool prepareForSleepSubscriptionPending: false
|
||||||
|
property double lastResumeSignalTimestamp: 0
|
||||||
|
|
||||||
readonly property string socketPath: Quickshell.env("DMS_SOCKET")
|
readonly property string socketPath: Quickshell.env("DMS_SOCKET")
|
||||||
|
|
||||||
@@ -463,10 +466,13 @@ Singleton {
|
|||||||
function onConnectionStateChanged() {
|
function onConnectionStateChanged() {
|
||||||
if (DMSService.isConnected) {
|
if (DMSService.isConnected) {
|
||||||
checkDMSCapabilities();
|
checkDMSCapabilities();
|
||||||
|
} else {
|
||||||
|
clearPrepareForSleepSubscriptionState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCapabilitiesReceived() {
|
function onCapabilitiesReceived() {
|
||||||
|
checkDMSCapabilities();
|
||||||
syncSleepInhibitor();
|
syncSleepInhibitor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,6 +484,13 @@ Singleton {
|
|||||||
function onCapabilitiesChanged() {
|
function onCapabilitiesChanged() {
|
||||||
checkDMSCapabilities();
|
checkDMSCapabilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDbusSignalReceived(subscriptionId, data) {
|
||||||
|
if (subscriptionId !== prepareForSleepSubscriptionId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
handlePrepareForSleepSignal(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
@@ -539,6 +552,61 @@ Singleton {
|
|||||||
loginctlAvailable = false;
|
loginctlAvailable = false;
|
||||||
console.log("SessionService: loginctl capability not available in DMS");
|
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() {
|
function getLoginctlState() {
|
||||||
@@ -604,7 +672,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wasSleeping && !preparingForSleep) {
|
if (wasSleeping && !preparingForSleep) {
|
||||||
sessionResumed();
|
emitSessionResumedOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
loginctlStateChanged();
|
loginctlStateChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user