1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-04 04:42:05 -04:00
Files
DankMaterialShell/quickshell/Services/LocationService.qml
Sunner 7bea6b4a62 Add GeoClue2 integration as alternative to IP location (#1856)
* feat: switch auto location in weather widget to use GeoClue2 instead of simple IP check

* nix: enable GeoClue2 service by default

* lint: fix line endings

* fix: fall back to IP location if GeoClue is not available
2026-02-27 22:29:08 -05:00

52 lines
1.1 KiB
QML

pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Common
Singleton {
id: root
readonly property bool locationAvailable: DMSService.isConnected && (DMSService.capabilities.length === 0 || DMSService.capabilities.includes("location"))
property var latitude: 0.0
property var longitude: 0.0
signal locationChanged(var data)
Component.onCompleted: {
console.info("LocationService: Initializing...");
getState();
}
Connections {
target: DMSService
function onLocationStateUpdate(data) {
if (locationAvailable) {
handleStateUpdate(data);
}
}
}
function handleStateUpdate(data) {
root.latitude = data.latitude;
root.longitude = data.longitude;
root.locationChanged(data)
}
function getState() {
if (!locationAvailable)
return;
DMSService.sendRequest("location.getState", null, response => {
if (response.result) {
handleStateUpdate(response.result);
}
});
}
}