1
0
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:
Sunner
2026-02-28 04:29:08 +01:00
committed by GitHub
parent ab211266a6
commit 7bea6b4a62
19 changed files with 974 additions and 71 deletions

View File

@@ -480,7 +480,7 @@ Singleton {
const cityName = SessionData.isGreeterMode ? GreetdSettings.weatherLocation : SettingsData.weatherLocation;
if (useAuto) {
getLocationFromIP();
getLocationFromService();
return;
}
@@ -511,8 +511,8 @@ Singleton {
cityGeocodeFetcher.running = true;
}
function getLocationFromIP() {
ipLocationFetcher.running = true;
function getLocationFromService() {
getLocationFromCoords(LocationService.latitude, LocationService.longitude);
}
function fetchWeather() {
@@ -583,53 +583,6 @@ Singleton {
}
}
Process {
id: ipLocationFetcher
command: lowPriorityCmd.concat(curlBaseCmd).concat(["http://ip-api.com/json/"])
running: false
stdout: StdioCollector {
onStreamFinished: {
const raw = text.trim();
if (!raw || raw[0] !== "{") {
root.handleWeatherFailure();
return;
}
try {
const data = JSON.parse(raw);
if (data.status === "fail") {
throw new Error("IP location lookup failed");
}
const lat = parseFloat(data.lat);
const lon = parseFloat(data.lon);
const city = data.city;
if (!city || isNaN(lat) || isNaN(lon)) {
throw new Error("Missing or invalid location data");
}
root.location = {
city: city,
latitude: lat,
longitude: lon
};
fetchWeather();
} catch (e) {
root.handleWeatherFailure();
}
}
}
onExited: exitCode => {
if (exitCode !== 0) {
root.handleWeatherFailure();
}
}
}
Process {
id: reverseGeocodeFetcher
running: false
@@ -872,6 +825,16 @@ Singleton {
}
}
Connections {
target: LocationService
function onLocationChanged(data) {
if (SettingsData.useAutoLocation) {
root.getLocationFromCoords(data.latitude, data.longitude)
}
}
}
Component.onCompleted: {
SettingsData.weatherCoordinatesChanged.connect(() => {
root.location = null;