Skip to content

Commit 80a5a19

Browse files
committed
snapshot
1 parent 9dab986 commit 80a5a19

32 files changed

Lines changed: 1090 additions & 863 deletions
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"sources": [
3-
{
4-
"enabled": true,
5-
"name": "Noctalia Plugins",
6-
"url": "https://github.com/noctalia-dev/noctalia-plugins"
7-
}
8-
],
9-
"states": {
10-
"ip-monitor": {
11-
"enabled": true,
12-
"sourceUrl": "https://github.com/noctalia-dev/noctalia-plugins"
2+
"sources": [
3+
{
4+
"enabled": true,
5+
"name": "Noctalia Plugins",
6+
"url": "https://github.com/noctalia-dev/noctalia-plugins"
7+
}
8+
],
9+
"states": {
10+
"ip-monitor": {
11+
"enabled": true,
12+
"sourceUrl": "https://github.com/noctalia-dev/noctalia-plugins"
13+
},
14+
"keybind-cheatsheet": {
15+
"enabled": true,
16+
"sourceUrl": "https://github.com/noctalia-dev/noctalia-plugins"
17+
},
18+
"privacy-indicator": {
19+
"enabled": true,
20+
"sourceUrl": "https://github.com/noctalia-dev/noctalia-plugins"
21+
}
1322
},
14-
"keybind-cheatsheet": {
15-
"enabled": true,
16-
"sourceUrl": "https://github.com/noctalia-dev/noctalia-plugins"
17-
},
18-
"privacy-indicator": {
19-
"enabled": true,
20-
"sourceUrl": "https://github.com/noctalia-dev/noctalia-plugins"
21-
}
22-
},
23-
"version": 2
23+
"version": 2
2424
}

home/linux/gui/base/noctalia/config/plugins/ip-monitor/BarWidget.qml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ Item {
4141
readonly property bool isVerticalBar: barPosition === "left" || barPosition === "right"
4242

4343
readonly property string currentIcon: {
44-
if (fetchState === "loading") return loadingIconKey;
45-
if (fetchState === "error") return errorIconKey;
44+
if (fetchState === "loading")
45+
return loadingIconKey;
46+
if (fetchState === "error")
47+
return errorIconKey;
4648
return successIconKey;
4749
}
4850

@@ -55,11 +57,11 @@ Item {
5557
onIpMonitorServiceChanged: {
5658
Logger.d("IpMonitor", "BarWidget ipMonitorService changed:", ipMonitorService !== null);
5759
}
58-
60+
5961
onCurrentIpChanged: {
6062
Logger.d("IpMonitor", "BarWidget currentIp changed to:", currentIp);
6163
}
62-
64+
6365
Component.onCompleted: {
6466
Logger.d("IpMonitor", "BarWidget completed refresh");
6567
}
@@ -84,8 +86,10 @@ Item {
8486
lines.push("");
8587
if (data.city || data.country) {
8688
var parts = [];
87-
if (data.city) parts.push(data.city);
88-
if (data.country) parts.push(data.country);
89+
if (data.city)
90+
parts.push(data.city);
91+
if (data.country)
92+
parts.push(data.country);
8993
lines.push(parts.join(", "));
9094
}
9195
}
@@ -144,4 +148,3 @@ Item {
144148
}
145149
}
146150
}
147-

home/linux/gui/base/noctalia/config/plugins/ip-monitor/Main.qml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,58 @@ Item {
1313
// IP Monitor Service
1414
Item {
1515
id: service
16-
16+
1717
property var ipData: null
1818
property string currentIp: "n/a"
1919
property string fetchState: "idle" // idle, loading, success, error
2020
property int lastFetchTime: 0
21-
21+
2222
// Increment this to trigger refresh in all listening widgets (for IPC)
2323
property int refreshTrigger: 0
24-
24+
2525
// Read global settings
2626
readonly property var cfg: root.pluginApi?.pluginSettings || ({})
2727
readonly property var defaults: root.pluginApi?.manifest?.metadata?.defaultSettings || ({})
2828
readonly property int refreshInterval: cfg.refreshInterval ?? defaults.refreshInterval ?? 300
29-
29+
3030
// Process for fetching IP info
3131
property Process ipFetchProcess: Process {
3232
running: false
33-
command: ["curl", "-s", "-m", "10", "https://ipinfo.io"]
33+
command: ["curl", "-s", "-m", "10", "http://ip-api.com/json/?fields=status,continent,country,regionName,city,zip,lat,lon,timezone,currency,org,as,query"]
3434
stdout: StdioCollector {
3535
id: stdoutCollector
3636
}
3737
stderr: StdioCollector {
3838
id: stderrCollector
3939
}
40-
40+
4141
onStarted: {
4242
service.fetchState = "loading";
4343
Logger.d("IpMonitor", "Service fetching IP info...");
4444
}
45-
46-
onExited: function(exitCode, exitStatus) {
45+
46+
onExited: function (exitCode, exitStatus) {
4747
var output = stdoutCollector.text;
4848
Logger.d("IpMonitor", "Service process exited:", exitCode, "length:", output.length);
49-
49+
5050
if (exitCode === 0 && output.length > 0) {
5151
try {
5252
var data = JSON.parse(output);
53-
if (data.ip) {
54-
service.ipData = data;
55-
service.currentIp = data.ip;
53+
if (data.status === "success") {
54+
service.ipData = {
55+
ip: data.query,
56+
city: data.city || "n/a",
57+
country: data.country || "n/a",
58+
continent: data.continent || "n/a",
59+
region: data.regionName || "n/a",
60+
postal: data.zip || "n/a",
61+
loc: (data.lat && data.lon) ? (data.lat + "," + data.lon) : "n/a",
62+
timezone: data.timezone || "n/a",
63+
currency: data.currency || "n/a",
64+
org: data.org || "n/a",
65+
as: data.as || "n/a"
66+
};
67+
service.currentIp = data.query;
5668
service.fetchState = "success";
5769
service.lastFetchTime = Date.now();
5870
Logger.d("IpMonitor", "Service IP fetched successfully:", service.currentIp);
@@ -73,20 +85,20 @@ Item {
7385
}
7486
}
7587
}
76-
88+
7789
property Timer autoRefreshTimer: Timer {
7890
interval: service.refreshInterval * 1000
7991
running: interval > 0
8092
repeat: true
8193
onTriggered: service.fetchIp()
8294
}
83-
95+
8496
Component.onCompleted: {
85-
Logger.i("IpMonitor", "Service initialized, first time fetching IP.");
97+
Logger.i("IpMonitor", "Service initialized, frist time fetching IP.");
8698
// Auto-fetch on startup
8799
Qt.callLater(() => fetchIp());
88100
}
89-
101+
90102
function fetchIp() {
91103
if (!service.ipFetchProcess) {
92104
Logger.e("IpMonitor", "Service ipFetchProcess is null!");
@@ -99,7 +111,7 @@ Item {
99111
Logger.d("IpMonitor", "Service fetch already in progress");
100112
}
101113
}
102-
114+
103115
function triggerRefresh() {
104116
Logger.d("IpMonitor", "Service triggerRefresh() called");
105117
refreshTrigger++;
@@ -115,20 +127,19 @@ Item {
115127
// IPC handlers
116128
IpcHandler {
117129
target: "plugin:ip-monitor"
118-
130+
119131
function refreshIp() {
120132
Logger.i("IpMonitor", "IPC refreshIp() called");
121133
service.triggerRefresh();
122134
ToastService.showNotice("Refreshing IP info...");
123135
}
124-
136+
125137
function toggle() {
126138
if (pluginApi) {
127139
pluginApi.withCurrentScreen(screen => {
128-
pluginApi.openPanel(screen);
129-
});
140+
pluginApi.openPanel(screen);
141+
});
130142
}
131143
}
132144
}
133145
}
134-

0 commit comments

Comments
 (0)