Added a check to see if wlsunset is enabled, if it isn't you can change

the NightLight settings.
DisplayTab: add wlsunsetCheck process
This commit is contained in:
Ly-sec 2025-08-28 17:06:53 +02:00
parent a845067cf0
commit 39d8d8bcfa
3 changed files with 31 additions and 5 deletions

View file

@ -2,6 +2,7 @@ import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Quickshell
import Quickshell.Io
import qs.Commons
import qs.Services
import qs.Widgets
@ -27,6 +28,27 @@ ColumnLayout {
}
}
// Check for wlsunset availability when enabling Night Light
Process {
id: wlsunsetCheck
command: ["which", "wlsunset"]
running: false
onExited: function (exitCode) {
if (exitCode === 0) {
Settings.data.nightLight.enabled = true
NightLightService.apply()
ToastService.showNotice("Night Light", "Enabled")
} else {
Settings.data.nightLight.enabled = false
ToastService.showWarning("Night Light", "wlsunset not installed")
}
}
stdout: StdioCollector {}
stderr: StdioCollector {}
}
// Helper functions to update arrays immutably
function addMonitor(list, name) {
const arr = (list || []).slice()
@ -240,8 +262,14 @@ ColumnLayout {
description: "Apply a warm color filter to reduce blue light emission."
checked: Settings.data.nightLight.enabled
onToggled: checked => {
Settings.data.nightLight.enabled = checked
NightLightService.apply()
if (checked) {
// Verify wlsunset exists before enabling
wlsunsetCheck.running = true
} else {
Settings.data.nightLight.enabled = false
NightLightService.apply()
ToastService.showNotice("Night Light", "Disabled")
}
}
}