1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 07:22:50 -05:00

gamma: display automation state in UI

This commit is contained in:
bbedward
2025-12-09 11:26:28 -05:00
parent da4561cb35
commit f88f1ea951
7 changed files with 279 additions and 68 deletions

View File

@@ -49,6 +49,7 @@ Singleton {
signal extWorkspaceStateUpdate(var data)
signal wlrOutputStateUpdate(var data)
signal evdevStateUpdate(var data)
signal gammaStateUpdate(var data)
signal openUrlRequested(string url)
signal appPickerRequested(var data)
@@ -267,9 +268,9 @@ Singleton {
function removeSubscription(service) {
if (activeSubscriptions.includes("all")) {
const allServices = ["network", "loginctl", "freedesktop", "gamma", "bluetooth", "dwl", "brightness", "extworkspace", "browser"]
const filtered = allServices.filter(s => s !== service)
subscribe(filtered)
const allServices = ["network", "loginctl", "freedesktop", "gamma", "bluetooth", "dwl", "brightness", "extworkspace", "browser"];
const filtered = allServices.filter(s => s !== service);
subscribe(filtered);
} else {
const filtered = activeSubscriptions.filter(s => s !== service);
if (filtered.length === 0) {
@@ -289,9 +290,9 @@ Singleton {
excludeServices = [excludeServices];
}
const allServices = ["network", "loginctl", "freedesktop", "gamma", "bluetooth", "cups", "dwl", "brightness", "extworkspace", "browser"]
const filtered = allServices.filter(s => !excludeServices.includes(s))
subscribe(filtered)
const allServices = ["network", "loginctl", "freedesktop", "gamma", "bluetooth", "cups", "dwl", "brightness", "extworkspace", "browser"];
const filtered = allServices.filter(s => !excludeServices.includes(s));
subscribe(filtered);
}
function handleSubscriptionEvent(response) {
@@ -355,16 +356,18 @@ Singleton {
if (data.capsLock !== undefined) {
capsLockState = data.capsLock;
}
evdevStateUpdate(data)
evdevStateUpdate(data);
} else if (service === "gamma") {
gammaStateUpdate(data);
} else if (service === "browser.open_requested") {
if (data.target) {
if (data.requestType === "url" || !data.requestType) {
openUrlRequested(data.target)
openUrlRequested(data.target);
} else {
appPickerRequested(data)
appPickerRequested(data);
}
} else if (data.url) {
openUrlRequested(data.url)
openUrlRequested(data.url);
}
}
}

View File

@@ -41,6 +41,18 @@ Singleton {
property bool automationAvailable: false
property bool gammaControlAvailable: false
property var gammaState: ({})
property int gammaCurrentTemp: gammaState?.currentTemp ?? 0
property string gammaNextTransition: gammaState?.nextTransition ?? ""
property string gammaSunriseTime: gammaState?.sunriseTime ?? ""
property string gammaSunsetTime: gammaState?.sunsetTime ?? ""
property string gammaDawnTime: gammaState?.dawnTime ?? ""
property string gammaNightTime: gammaState?.nightTime ?? ""
property bool gammaIsDay: gammaState?.isDay ?? true
property real gammaSunPosition: gammaState?.sunPosition ?? 0
property int gammaLowTemp: gammaState?.config?.LowTemp ?? 0
property int gammaHighTemp: gammaState?.config?.HighTemp ?? 0
function markDeviceUserControlled(deviceId) {
const newControlled = Object.assign({}, userControlledDevices);
newControlled[deviceId] = Date.now();
@@ -809,6 +821,10 @@ Singleton {
osdSuppressTimer.restart();
}
}
function onGammaStateUpdate(data) {
root.gammaState = data;
}
}
// Session Data Connections

View File

@@ -58,43 +58,12 @@ Singleton {
property var monitorOffMonitor: null
property var lockMonitor: null
property var suspendMonitor: null
property var mediaInhibitor: null
property var lockComponent: null
function wake() {
requestMonitorOn();
}
function createMediaInhibitor() {
if (!idleInhibitorAvailable) {
return;
}
if (mediaInhibitor) {
mediaInhibitor.destroy();
mediaInhibitor = null;
}
const inhibitorString = `
import QtQuick
import Quickshell.Wayland
IdleInhibitor {
active: false
}
`;
mediaInhibitor = Qt.createQmlObject(inhibitorString, root, "IdleService.MediaInhibitor");
mediaInhibitor.active = Qt.binding(() => root.mediaPlaying);
}
function destroyMediaInhibitor() {
if (mediaInhibitor) {
mediaInhibitor.destroy();
mediaInhibitor = null;
}
}
function createIdleMonitors() {
if (!idleMonitorAvailable) {
console.info("IdleService: IdleMonitor not available, skipping creation");
@@ -152,10 +121,6 @@ Singleton {
root.requestSuspend();
}
});
if (SettingsData.preventIdleForMedia) {
createMediaInhibitor();
}
} catch (e) {
console.warn("IdleService: Error creating IdleMonitors:", e);
}
@@ -176,17 +141,6 @@ Singleton {
}
}
Connections {
target: SettingsData
function onPreventIdleForMediaChanged() {
if (SettingsData.preventIdleForMedia) {
createMediaInhibitor();
} else {
destroyMediaInhibitor();
}
}
}
Component.onCompleted: {
if (!idleMonitorAvailable) {
console.warn("IdleService: IdleMonitor not available - power management disabled. This requires a newer version of Quickshell.");