feat(network): add clickable network widget and launch nmtui

This commit is contained in:
tux
2025-09-27 21:03:15 +05:30
parent 7410ad016f
commit 864f39fe8d

View File

@@ -1,3 +1,5 @@
import { Gdk } from "ags/gtk4";
import { execAsync } from "ags/process";
import AstalNetwork from "gi://AstalNetwork"; import AstalNetwork from "gi://AstalNetwork";
import { createBinding } from "gnim"; import { createBinding } from "gnim";
@@ -19,7 +21,9 @@ export const Network = () => {
const wifi = net.wifi; const wifi = net.wifi;
switch (wifi.internet) { switch (wifi.internet) {
case 0: case 0:
return wifi.ssid; const ssid = wifi.ssid;
let text = ssid.length > 10 ? ssid.substring(0, 10) + "..." : ssid;
return text;
case 1: case 1:
return "Connecting"; return "Connecting";
case 2: case 2:
@@ -30,11 +34,17 @@ export const Network = () => {
}; };
return ( return (
<box cssClasses={["pill"]}> <button
cssClasses={["pill"]}
cursor={Gdk.Cursor.new_from_name("pointer", null)}
onClicked={() =>
execAsync(`wezterm start --class wezterm-floating nmtui`)
}
>
<box spacing={5}> <box spacing={5}>
<image iconName="fa-wifi-symbolic" /> <image iconName="fa-wifi-symbolic" />
<label label={connnectivity((c) => getNetworkText(c, network))} /> <label label={connnectivity((c) => getNetworkText(c, network))} />
</box> </box>
</box> </button>
); );
}; };