Network module: Wi-Fi and wired status, connect to Wi-Fi networks, Wi-Fi and airplane switches
CI / test (push) Failing after 18s
CI / test (push) Failing after 18s
- New `network` panel module (in the default panel, before the battery and the clock): signal bars and the
Wi-Fi network's name, a plug when wired, crossed-out bars offline or in airplane mode. Its
popup shows the status and the last action's outcome ("Couldn't connect to X: wrong
password?"), switches for Wi-Fi and airplane mode, and the networks in range (strongest
access point per name, the one in use first). Click a saved or open network to connect, a new
secured one to type its password in a field under it (Enter or Connect), the one in use to
disconnect, or "Forget" on a saved one. Opening the popup asks for a scan.
- compositor/network: NetworkManager over D-Bus through a small D-Bus client of our own
(wire format, EXTERNAL auth, async calls) on the existing @sys socket calls, so neither host
needed new imports. One ObjectManager.GetManagedObjects + GetAll every 2 s; GetSettings once
per saved connection; RequestScan, Device.Disconnect, WirelessEnabled / WwanEnabled,
ActivateConnection (saved), AddAndActivateConnection (new: open, WPA/WPA2 PSK, WPA3 SAE) and
Settings.Connection.Delete. Without NetworkManager it falls back to read-only status from
/proc/net/dev, /proc/net/wireless and /sys/class/net (no network names there), and looks for
NetworkManager again every 30 s.
- New `network` capability (wit/capabilities.wit): status, wifi-networks, scan, connect,
disconnect, forget, set-wifi-enabled, set-airplane-mode. Served from host tables 8/9 and a
`network(network-request)` request by the wasmer/wasmtime stub (compositor/wasm), host-wasm
and the MoonBit wasmhost. The stub's build_list learned bool fields; request strings are
wiped after use (Wi-Fi passwords).
- Running out of module instances now says "too many modules loaded".
- Deferred: VPN, hotspot, hidden networks, WEP and 802.1X (enterprise) networks, IP settings,
mobile broadband beyond the airplane switch, D-Bus signals (state is polled).
- Tests: D-Bus wire format (incl. the well-known Hello bytes), NetworkManager objects -> status
and list, security settings, /proc parsing; the module through the shell against a fake
backend (list, connect/forget/disconnect, password entry, switches, read-only); a host-wasm
test; and scripts/test-network-dbus.sh, which runs the backend against python-dbusmock's
NetworkManager on a private bus.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hizqNXcNDuef3gxa7D
This commit is contained in:
43 files changed
+4101
-32
No files matched your search
@@ -206,3 +206,50 @@ interface battery {
|
||||
}
|
||||
read: func() -> status;
|
||||
}
|
||||
|
||||
/// Network status and control (NetworkManager), for the network panel module. The shell talks to
|
||||
/// NetworkManager over D-Bus; without it, status comes read-only from /sys/class/net and
|
||||
/// /proc/net, `can-manage` is false and the actions do nothing.
|
||||
interface network {
|
||||
record net-status {
|
||||
/// 0 offline, 1 wired, 2 Wi-Fi, 3 connecting.
|
||||
state: u32,
|
||||
/// Signal of the Wi-Fi network in use, 0..100 (0 when not on Wi-Fi).
|
||||
signal: u32,
|
||||
/// The Wi-Fi network's name, else the connection's (e.g. "Wired connection 1"); "" offline.
|
||||
name: string,
|
||||
/// An action's outcome or why it failed, to show ("" for nothing).
|
||||
message: string,
|
||||
wifi-enabled: bool,
|
||||
/// Wi-Fi and mobile broadband both off.
|
||||
airplane: bool,
|
||||
/// The network can be changed from here (NetworkManager answers).
|
||||
can-manage: bool,
|
||||
/// There is a Wi-Fi device.
|
||||
has-wifi: bool,
|
||||
}
|
||||
record wifi-network {
|
||||
ssid: string,
|
||||
/// 0..100.
|
||||
signal: u32,
|
||||
secured: bool,
|
||||
/// The one in use.
|
||||
active: bool,
|
||||
/// There is a saved connection for it: connecting needs no password.
|
||||
saved: bool,
|
||||
}
|
||||
status: func() -> net-status;
|
||||
/// Wi-Fi networks in range, the one in use first, then by signal (empty with Wi-Fi off).
|
||||
wifi-networks: func() -> list<wifi-network>;
|
||||
/// Ask the Wi-Fi device to look for networks (the list fills in over a few seconds).
|
||||
scan: func();
|
||||
/// Connect to `ssid`: a saved network as saved, a new one with `password` ("" when open).
|
||||
/// WPA/WPA2/WPA3 personal and open networks; the outcome shows in `status.message`.
|
||||
connect: func(ssid: string, password: string);
|
||||
/// Disconnect the Wi-Fi device.
|
||||
disconnect: func();
|
||||
/// Delete the saved connection(s) for `ssid`.
|
||||
forget: func(ssid: string);
|
||||
set-wifi-enabled: func(on: bool);
|
||||
set-airplane-mode: func(on: bool);
|
||||
}
|
||||
+12
-1
@@ -54,7 +54,9 @@ interface plasmoids {
|
||||
/// i32 ('i') or a LE u32 byte length + UTF-8 ('s'). `which`: 0 apps (sssss: id name comment
|
||||
/// category glyph), 1 windows (isii: id title focused minimized), 2 layouts (s), 3 modules
|
||||
/// (sssi: id name path loaded), 4 instances (sss: slot module name), 5 wallpapers (s), 6 session
|
||||
/// settings (s), 7 icons (si: app id, raster image handle from `raster.load-image`) served by `icons.app-icon`.
|
||||
/// settings (s), 7 icons (si: app id, raster image handle from `raster.load-image`) served by `icons.app-icon`,
|
||||
/// 8 network status (one row, iissiiii: state signal name message wifi-enabled airplane
|
||||
/// can-manage has-wifi), 9 Wi-Fi networks (siiii: ssid signal secured active saved).
|
||||
publish-table: func(which: u32, rows: list<u8>);
|
||||
/// Layout mode (0 tiling, 1 monocle, 2 floating) and whether the Interface Explorer is on.
|
||||
publish-state: func(layout-mode: s32, inspector-on: bool);
|
||||
@@ -91,6 +93,14 @@ interface plasmoids {
|
||||
}
|
||||
publish-windows: func(wins: list<window-entry>);
|
||||
|
||||
/// A network module's action: 0 scan, 1 disconnect, 2/3 Wi-Fi off/on, 4/5 airplane mode
|
||||
/// off/on, 6 connect (ssid, password), 7 forget (ssid).
|
||||
record network-request {
|
||||
action: s32,
|
||||
ssid: string,
|
||||
password: string,
|
||||
}
|
||||
|
||||
/// A module turning a session setting on or off.
|
||||
record setting-change {
|
||||
index: s32,
|
||||
@@ -118,6 +128,7 @@ interface plasmoids {
|
||||
set-screen-off(s32),
|
||||
set-suspend-after(s32),
|
||||
power-action(s32),
|
||||
network(network-request),
|
||||
}
|
||||
/// The next pending request, oldest first.
|
||||
next-request: func() -> option<request>;
|
||||
|
||||
@@ -82,6 +82,7 @@ world plasmoid-host {
|
||||
import screenshot;
|
||||
import power;
|
||||
import battery;
|
||||
import network;
|
||||
export plasmoid;
|
||||
}
|
||||
|
||||
@@ -116,3 +117,10 @@ world battery-widget {
|
||||
import battery;
|
||||
export module-config;
|
||||
}
|
||||
|
||||
/// Network status (Ethernet, Wi-Fi name and signal, offline) and a popup to pick a Wi-Fi network,
|
||||
/// connect, disconnect, and switch Wi-Fi or airplane mode.
|
||||
world network-widget {
|
||||
include widget;
|
||||
import network;
|
||||
}
|
||||
Reference in new issue
Block a user