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" spawn-sh-at-startup "wl-paste --type image --watch cliphist store"
// wlsunset // wlsunset
spawn-at-startup "sunset" // spawn-at-startup "sunset"
// Logitech // Logitech
spawn-sh-at-startup "solaar -w hide" spawn-sh-at-startup "solaar -w hide"

View File

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

View File

@@ -7,53 +7,87 @@ import qs.Noctalia
import qs.Services import qs.Services
import qs.Utils import qs.Utils
// Unified system card: monitors CPU, temp, memory, disk ColumnLayout {
NBox {
id: root id: root
compact: true spacing: 0
ColumnLayout { RowLayout {
id: content id: sunsetControlRow
anchors.fill: parent Layout.fillWidth: true
anchors.margins: Style.marginXS
spacing: Style.marginS
MonitorSlider { NIconButton {
icon: "cpu-usage" id: barLyricsButton
value: SystemStatService.cpuUsage
from: 0 implicitHeight: 32
to: 100 implicitWidth: 32
colorFill: Colors.teal colorBg: SunsetService.isRunning ? Colors.flamingo : Color.transparent
Layout.fillWidth: true colorBgHover: Colors.flamingo
colorFg: SunsetService.isRunning ? Colors.base : Colors.flamingo
icon: "sunset-2"
onClicked: SunsetService.toggleSunset()
} }
MonitorSlider { NText {
icon: "memory"
value: SystemStatService.memPercent
from: 0
to: 100
colorFill: Colors.green
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: SunsetService.isRunning ? "Temp: " + SunsetService.temperature + " K" : "Sunset Off"
} }
MonitorSlider { }
icon: "cpu-temperature"
value: SystemStatService.cpuTemp NBox {
from: 0 id: monitors
to: 100
colorFill: Colors.yellow compact: true
Layout.fillWidth: true Layout.fillWidth: true
} Layout.fillHeight: true
ColumnLayout {
id: content
anchors.fill: parent
anchors.margins: Style.marginS
spacing: Style.marginS
MonitorSlider {
icon: "cpu-usage"
value: SystemStatService.cpuUsage
from: 0
to: 100
colorFill: Colors.teal
Layout.fillWidth: true
}
MonitorSlider {
icon: "memory"
value: SystemStatService.memPercent
from: 0
to: 100
colorFill: Colors.green
Layout.fillWidth: true
}
MonitorSlider {
icon: "cpu-temperature"
value: SystemStatService.cpuTemp
from: 0
to: 100
colorFill: Colors.yellow
Layout.fillWidth: true
}
MonitorSlider {
icon: "storage"
value: SystemStatService.diskPercent
from: 0
to: 100
colorFill: Colors.peach
Layout.fillWidth: true
}
MonitorSlider {
icon: "storage"
value: SystemStatService.diskPercent
from: 0
to: 100
colorFill: Colors.peach
Layout.fillWidth: true
} }
} }

View File

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

View File

@@ -11,6 +11,7 @@ Singleton {
property alias notifications: adapter.notifications property alias notifications: adapter.notifications
property alias location: adapter.location property alias location: adapter.location
property alias wifiEnabled: adapter.wifiEnabled property alias wifiEnabled: adapter.wifiEnabled
property alias sunsetDefaultEnabled: adapter.sunsetDefaultEnabled
property string settingsFilePath: Qt.resolvedUrl("../Assets/Config/Settings.json") property string settingsFilePath: Qt.resolvedUrl("../Assets/Config/Settings.json")
FileView { FileView {
@@ -29,6 +30,7 @@ Singleton {
property JsonObject notifications property JsonObject notifications
property string location: "New York" property string location: "New York"
property bool wifiEnabled: true property bool wifiEnabled: true
property bool sunsetDefaultEnabled: true
notifications: JsonObject { notifications: JsonObject {
property bool doNotDisturb: false 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 active: CacheService.loaded && NukeKded6.done
sourceComponent: Item { sourceComponent: Item {
Component.onCompleted: {
SunsetService;
}
Notification { Notification {
id: notification id: notification
} }