script: fix 'apply-color's

This commit is contained in:
2025-10-18 18:22:22 +02:00
parent 3a903205d9
commit 98fe49368b
18 changed files with 103 additions and 41 deletions

View File

@@ -25,21 +25,16 @@ Singleton {
Logger.log("IpService", "Fetched IP: " + newIP);
if (newIP !== ip) {
ip = newIP;
countryCode = "N/A";
fetchGeoInfo(true); // Fetch geo info only if IP has changed
}
} else {
ip = "N/A";
countryCode = "N/A";
Logger.error("IpService", "IP response does not contain 'ip' field");
}
} catch (e) {
ip = "N/A";
countryCode = "N/A";
Logger.error("IpService", "Failed to parse IP response: " + e);
}
} else {
ip = "N/A";
countryCode = "N/A";
Logger.error("IpService", "Failed to fetch IP");
}
});
@@ -53,7 +48,8 @@ Singleton {
let url = geoURL + ip;
if (geoURLToken)
url += "?token=" + geoURLToken;
cacheFileAdapter.geoInfo = null
curl.fetch(url, function(success, data) {
if (success) {
try {
@@ -63,17 +59,13 @@ Singleton {
Logger.log("IpService", "Fetched country code: " + newCountryCode);
countryCode = newCountryCode;
} else {
countryCode = "N/A";
Logger.error("IpService", "Geo response does not contain 'country_code' field");
}
cacheFileAdapter.ip = ip;
cacheFileAdapter.geoInfo = response;
} catch (e) {
countryCode = "N/A";
Logger.error("IpService", "Failed to parse geo response: " + e);
}
} else {
countryCode = "N/A";
Logger.error("IpService", "Failed to fetch geo info");
}
SendNotification.show("New IP", `IP: ${ip}\nCountry: ${countryCode}`);

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
path=$(dirname "$(readlink -f "$0")")
. "$path"/../.utils/apply-color-parse-arg