quickshell: wlsunset support

This commit is contained in:
2025-11-16 14:15:36 +01:00
parent e658fa7db8
commit 9b279d543b
7 changed files with 180 additions and 37 deletions

View File

@@ -137,7 +137,7 @@ spawn-sh-at-startup "wl-paste --type text --watch cliphist store"
spawn-sh-at-startup "wl-paste --type image --watch cliphist store"
// wlsunset
spawn-at-startup "sunset"
// spawn-at-startup "sunset"
// Logitech
spawn-sh-at-startup "solaar -w hide"

View File

@@ -5,5 +5,6 @@
},
"primaryColor": "#89b4fa",
"showLyricsBar": false,
"sunsetDefaultEnabled": true,
"wifiEnabled": true
}

View File

@@ -7,17 +7,49 @@ import qs.Noctalia
import qs.Services
import qs.Utils
// Unified system card: monitors CPU, temp, memory, disk
NBox {
ColumnLayout {
id: root
spacing: 0
RowLayout {
id: sunsetControlRow
Layout.fillWidth: true
NIconButton {
id: barLyricsButton
implicitHeight: 32
implicitWidth: 32
colorBg: SunsetService.isRunning ? Colors.flamingo : Color.transparent
colorBgHover: Colors.flamingo
colorFg: SunsetService.isRunning ? Colors.base : Colors.flamingo
icon: "sunset-2"
onClicked: SunsetService.toggleSunset()
}
NText {
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: SunsetService.isRunning ? "Temp: " + SunsetService.temperature + " K" : "Sunset Off"
}
}
NBox {
id: monitors
compact: true
Layout.fillWidth: true
Layout.fillHeight: true
ColumnLayout {
id: content
anchors.fill: parent
anchors.margins: Style.marginXS
anchors.margins: Style.marginS
spacing: Style.marginS
MonitorSlider {
@@ -59,3 +91,5 @@ NBox {
}
}
}

View File

@@ -48,4 +48,12 @@ Item {
target: "recording"
}
IpcHandler {
function toggleSunset() {
SunsetService.toggleSunset();
}
target: "sunset"
}
}

View File

@@ -11,6 +11,7 @@ Singleton {
property alias notifications: adapter.notifications
property alias location: adapter.location
property alias wifiEnabled: adapter.wifiEnabled
property alias sunsetDefaultEnabled: adapter.sunsetDefaultEnabled
property string settingsFilePath: Qt.resolvedUrl("../Assets/Config/Settings.json")
FileView {
@@ -29,6 +30,7 @@ Singleton {
property JsonObject notifications
property string location: "New York"
property bool wifiEnabled: true
property bool sunsetDefaultEnabled: true
notifications: JsonObject {
property bool doNotDisturb: false

View File

@@ -0,0 +1,94 @@
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Services
import qs.Utils
pragma Singleton
Singleton {
id: root
property bool defaultRunning: SettingsService.sunsetDefaultEnabled
property double _latitude: -1
property double _longitude: -1
property alias isRunning: sunsetProcess.running
property int temperature: 0
function startSunset() {
if (isRunning)
return ;
if (_latitude == -1 || _longitude == -1) {
Logger.warn("Sunset", "Cannot start sunset process, invalid coordinates");
return ;
}
sunsetProcess.command = ["wlsunset", "-l", _latitude.toString(), "-L", _longitude.toString()];
sunsetProcess.running = true;
}
function stopSunset() {
if (!isRunning)
return ;
sunsetProcess.running = false;
}
function toggleSunset() {
if (isRunning)
stopSunset();
else
startSunset();
}
function setLat(lat) {
_latitude = lat;
Logger.log("Sunset", "Updated latitude to " + lat);
checkStart();
}
function setLong(lng) {
_longitude = lng;
Logger.log("Sunset", "Updated longitude to " + lng);
checkStart();
}
function checkStart() {
if (_latitude != -1 && _longitude != -1 && defaultRunning && !isRunning)
startSunset();
}
Connections {
target: LocationService.data
onLatitudeChanged: {
setLat(LocationService.data.latitude);
}
onLongitudeChanged: {
setLong(LocationService.data.longitude);
}
}
Process {
id: sunsetProcess
running: false
stderr: SplitParser {
splitMarker: "\n"
onRead: (line) => {
// console.log(line);
var tempMatch = line.match(/setting temperature to (\d+) K/);
if (tempMatch && tempMatch.length == 2) {
temperature = parseInt(tempMatch[1]);
Logger.log("Sunset", "Updated temperature to " + temperature + " K");
}
}
}
}
NetworkFetch {
id: curl
}
}

View File

@@ -16,6 +16,10 @@ ShellRoot {
active: CacheService.loaded && NukeKded6.done
sourceComponent: Item {
Component.onCompleted: {
SunsetService;
}
Notification {
id: notification
}