1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-11 07:52:50 -05:00

re-nice weather curl commands

This commit is contained in:
bbedward
2025-09-11 22:52:01 -04:00
parent 988d5c2fc3
commit 63c54b5611

View File

@@ -42,6 +42,9 @@ Singleton {
property int minFetchInterval: 30000
property int persistentRetryCount: 0
readonly property var lowPriorityCmd: ["nice", "-n", "19", "ionice", "-c3"]
readonly property var curlBaseCmd: ["curl", "-sS", "--fail", "--connect-timeout", "3", "--max-time", "6", "--limit-rate", "100k", "--compressed"]
property var weatherIcons: ({
"0": "clear_day",
"1": "clear_day",
@@ -235,12 +238,13 @@ Singleton {
}
function getLocationFromCoords(lat, lon) {
reverseGeocodeFetcher.command = ["bash", "-c", "curl -s --connect-timeout 10 --max-time 30 'https://nominatim.openstreetmap.org/reverse?lat=" + lat + "&lon=" + lon + "&format=json&addressdetails=1&accept-language=en' -H 'User-Agent: DankMaterialShell Weather Widget'"]
const url = "https://nominatim.openstreetmap.org/reverse?lat=" + lat + "&lon=" + lon + "&format=json&addressdetails=1&accept-language=en"
reverseGeocodeFetcher.command = lowPriorityCmd.concat(curlBaseCmd).concat(["-H", "User-Agent: DankMaterialShell Weather Widget", url])
reverseGeocodeFetcher.running = true
}
function getLocationFromCity(city) {
cityGeocodeFetcher.command = ["bash", "-c", "curl -s --connect-timeout 10 --max-time 30 '" + getGeocodingUrl(city) + "'"]
cityGeocodeFetcher.command = lowPriorityCmd.concat(curlBaseCmd).concat([getGeocodingUrl(city)])
cityGeocodeFetcher.running = true
}
@@ -274,7 +278,8 @@ Singleton {
root.lastFetchTime = now
root.weather.loading = true
weatherFetcher.command = ["bash", "-c", "curl -s --connect-timeout 10 --max-time 30 '" + apiUrl + "'"]
const weatherCmd = lowPriorityCmd.concat(["curl", "-sS", "--fail", "--connect-timeout", "3", "--max-time", "6", "--limit-rate", "150k", "--compressed"])
weatherFetcher.command = weatherCmd.concat([apiUrl])
weatherFetcher.running = true
}
@@ -282,6 +287,11 @@ Singleton {
root.lastFetchTime = 0 // Reset throttle
fetchWeather()
}
function nextInterval() {
const jitter = Math.floor(Math.random() * 15000) - 7500
return Math.max(60000, root.updateInterval + jitter)
}
function handleWeatherSuccess() {
root.retryAttempts = 0
@@ -312,7 +322,7 @@ Singleton {
Process {
id: ipLocationFetcher
command: ["curl", "-s", "--connect-timeout", "5", "--max-time", "10", "http://ipinfo.io/json"]
command: lowPriorityCmd.concat(curlBaseCmd).concat(["http://ipinfo.io/json"])
running: false
stdout: StdioCollector {
@@ -533,12 +543,13 @@ Singleton {
Timer {
id: updateTimer
interval: root.updateInterval
interval: nextInterval()
running: root.refCount > 0 && SettingsData.weatherEnabled
repeat: true
triggeredOnStart: true
onTriggered: {
root.fetchWeather()
interval = nextInterval()
}
}