1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-09 23:15:38 -05:00

improve err handling

This commit is contained in:
bbedward
2025-08-13 10:02:52 -04:00
parent 1b85a7ef4d
commit e218e77380

View File

@@ -93,8 +93,8 @@ Singleton {
function enableNightMode() { function enableNightMode() {
if (nightModeActive) return; if (nightModeActive) return;
nightModeActive = true; // Test if gammastep exists before enabling
SessionData.setNightModeEnabled(true); gammaStepTestProcess.running = true;
} }
function updateNightModeTemperature(temperature) { function updateNightModeTemperature(temperature) {
@@ -235,6 +235,25 @@ Singleton {
} }
Process {
id: gammaStepTestProcess
command: ["which", "gammastep"]
running: false
onExited: function(exitCode) {
if (exitCode === 0) {
// gammastep exists, enable night mode
nightModeActive = true;
SessionData.setNightModeEnabled(true);
} else {
// gammastep not found
console.warn("BrightnessService: gammastep not found");
ToastService.showWarning("Night mode failed: gammastep not found");
}
}
}
Process { Process {
id: gammaStepProcess id: gammaStepProcess
@@ -245,12 +264,12 @@ Singleton {
running: nightModeActive running: nightModeActive
onExited: function(exitCode) { onExited: function(exitCode) {
// Only show error if we're still supposed to be active (not manually disabled) // If process exits with non-zero code while we think it should be running
if (exitCode !== 0 && nightModeActive) { if (nightModeActive && exitCode !== 0) {
console.warn("BrightnessService: Failed to enable night mode (gammastep not found or error)"); console.warn("BrightnessService: Night mode process crashed with exit code:", exitCode);
nightModeActive = false; nightModeActive = false;
SessionData.setNightModeEnabled(false); SessionData.setNightModeEnabled(false);
ToastService.showWarning("Night mode failed: gammastep not found or error occurred"); ToastService.showWarning("Night mode failed: process crashed");
} }
} }
} }