mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-04 21:02:06 -04:00
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
This commit is contained in:
51
quickshell/Services/LocationService.qml
Normal file
51
quickshell/Services/LocationService.qml
Normal file
@@ -0,0 +1,51 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user