diff --git a/Services/BrightnessService.qml b/Services/BrightnessService.qml index 786a2015..2a9b40fb 100644 --- a/Services/BrightnessService.qml +++ b/Services/BrightnessService.qml @@ -93,8 +93,8 @@ Singleton { function enableNightMode() { if (nightModeActive) return; - nightModeActive = true; - SessionData.setNightModeEnabled(true); + // Test if gammastep exists before enabling + gammaStepTestProcess.running = true; } 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 { id: gammaStepProcess @@ -245,12 +264,12 @@ Singleton { running: nightModeActive onExited: function(exitCode) { - // Only show error if we're still supposed to be active (not manually disabled) - if (exitCode !== 0 && nightModeActive) { - console.warn("BrightnessService: Failed to enable night mode (gammastep not found or error)"); + // If process exits with non-zero code while we think it should be running + if (nightModeActive && exitCode !== 0) { + console.warn("BrightnessService: Night mode process crashed with exit code:", exitCode); nightModeActive = false; SessionData.setNightModeEnabled(false); - ToastService.showWarning("Night mode failed: gammastep not found or error occurred"); + ToastService.showWarning("Night mode failed: process crashed"); } } }