From 565b0f8cb81fa17643d50ffc708932aa26635cfe Mon Sep 17 00:00:00 2001 From: cbm Date: Sun, 8 Nov 2026 23:01:17 +0100 Subject: [PATCH 1/4] omamobile-shell 0.2.107: a Hotspot page behind the tile's chevron The Hotspot tile only switched the hotspot on and off; its long-press opened the Wi-Fi picker, which says nothing about the hotspot itself. The tile now has a chevron, like Wi-Fi and Bluetooth, and behind it a page (HotspotPanel.qml): the switch with the number of connected devices, the network name and the password (hidden, an eye shows it), a QR code that joins another phone (the usual WIFI: string, drawn with qrencode, now a dependency), and a pencil that makes name and password editable; a running hotspot restarts with the new values. Data and actions go through hotspot-panel.sh next to the page, as the tiles' tile-state.sh and tile-action.sh. It reads NetworkManager's "Hotspot" connection (the one tile-action.sh makes) and changes it with `nmcli connection modify`. Two more boxes, "Share VPN" (devices on the hotspot reach what the phone's VPN reaches) and "Route all traffic through the VPN", are drawn only when the backend reports them: NetworkManager's shared mode has no such switch, so they stay hidden there. A device that brings its own hotspot (hostapd, its own firewall) can answer the page's verbs from an executable at /etc/omamobile/hotspot-backend (or ~/.config/omamobile/hotspot-backend) and gets the boxes; the script still adds the QR code for it. This is what the Pixel 9a runs today (its hotspot is hostapd on ap0, #523), so the whole page, boxes included, was used there; the NetworkManager path is covered by the test. The page is a layer-shell window of its own, like the Wi-Fi picker, with the same back glyph, and `omarchy-shell shell summon omamobile.quicksettings '{"page":"hotspot"}'` opens it. Tests: test/hotspot-panel.sh (the NetworkManager state line, the QR code drawn once and dropped after a change, name and password checks, a change on a running and on a stopped hotspot, the VPN boxes refused there, no qrencode, a device's own backend), and test/all checks that the tile's chevron opens the page, that the page runs the script next to it and that the password field is masked. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01176vSgL9PRmxFqbaB3D9vk --- packages/omamobile-shell/PKGBUILD | 1 + packages/omamobile-shell/README.md | 2 +- .../omamobile.quicksettings/HotspotPanel.qml | 642 ++++++++++++++++++ .../omamobile.quicksettings/QuickSettings.qml | 38 +- .../omamobile.quicksettings/hotspot-panel.sh | 123 ++++ packages/omamobile-shell/test/all | 8 + .../omamobile-shell/test/hotspot-panel.sh | 113 +++ packages/omamobile-shell/version | 2 +- 8 files changed, 923 insertions(+), 6 deletions(-) create mode 100644 packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml create mode 100755 packages/omamobile-shell/plugins/omamobile.quicksettings/hotspot-panel.sh create mode 100755 packages/omamobile-shell/test/hotspot-panel.sh diff --git a/packages/omamobile-shell/PKGBUILD b/packages/omamobile-shell/PKGBUILD index c3c32ff32..0e80472dc 100644 --- a/packages/omamobile-shell/PKGBUILD +++ b/packages/omamobile-shell/PKGBUILD @@ -14,6 +14,7 @@ depends=(omarchy omamobile-apps 'omamobile-omarchy>=0.1.11' 'omamobile-owl-widge iproute2 jq # omamobile-sleepd: ss for SSH sessions; jq also for omamobile-keys # Both are in Omarchy's base package list, which root images install. dnsmasq # the Hotspot tile: NetworkManager's shared mode hands out addresses with it + qrencode # the Hotspot page: the QR code that joins a device to the hotspot foot xdg-terminal-exec # guard for hand-built/partial installations xdg-desktop-portal-gnome) # the file chooser (portal/hyprland-portals.conf) optdepends=('fprintd: fingerprint setup and unlock (with omamobile-fingerprint)' diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index e726618fe..b650bc530 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -5,7 +5,7 @@ Omarchy Mobile's phone profile for Omarchy's own shell. It isn't a fork: these a | Path | What it is | | --- | --- | | `plugins/omamobile.bar` | Phone status bar (a full `bar` plugin) | -| `plugins/omamobile.quicksettings` | Pull-down quick settings | +| `plugins/omamobile.quicksettings` | Pull-down quick settings; the Wi-Fi, Bluetooth and Hotspot tiles have pages behind their chevrons (the Hotspot page: name, password, a QR code to join, and `hotspot-panel.sh`'s VPN boxes where a device's hotspot backend has them) | | `plugins/omamobile.launcher` | Home bar: app search, app grid and a prompt to the user's Omarchy default agent; over an app, the home pill in a 44 px strip that reserves its height, so apps end above it (as on Android it is just the pill: double-tap for the keyboard, hold for the voice bar) | | `plugins/omamobile.switcher` | Recent apps: swipe up on the dock, or swipe up and hold on the home pill over an app; hold a card to show the app with another one, or give it its own screen again | | `plugins/omamobile.home` | Home screens: pages of apps and widgets on the wallpaper, with an edit mode. The built-ins include every widget in Simon Schubert's [omarchy-widgets](https://github.com/SimonSchubert/omarchy-widgets) `widgets/simonschubert/` (MIT): the OWL originals, from the `omamobile-owl-widgets` package, run by our own OWL runtime (`owl/`, see `owl/SPEC-NOTES.md`). `widgets/OWL.md` is his OWL language guide (MIT, `widgets/LICENSE-owl-guide`) | diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml new file mode 100644 index 000000000..49bd6d8f6 --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml @@ -0,0 +1,642 @@ +// SPDX-License-Identifier: MIT +import QtQuick +import Quickshell +import Quickshell.Io +import Quickshell.Wayland +import qs.Commons +import qs.Commons as Commons +import qs.Ui + +// The page behind the Hotspot tile's chevron, like the Wi-Fi picker: the +// hotspot's switch, its network name and password (the pencil edits them), +// a QR code that joins a phone to it, and the "Share VPN" box: devices on +// the hotspot may use the phone's VPN connection as well, while the hotspot +// runs; off unless the box is ticked, and shown only where the hotspot +// backend supports it. Data and actions come from hotspot-panel.sh next to +// this file, which knows the hotspot backends (see its header). +Item { + id: root + + property bool opened: false + property color foreground: Commons.Color.popups.text + // From the tile, so the switch follows a tap at once + property bool hotspotOn: false + + signal backRequested() + signal toggleRequested() + + readonly property int touchSize: Math.max(44, Style.space(48)) + readonly property int pad: Style.spacing.panelPadding + readonly property string helper: decodeURIComponent(String(Qt.resolvedUrl("hotspot-panel.sh")).replace(/^file:\/\//, "")) + + property string ssid: "" + property string psk: "" + property string qrPath: "" + property bool vpnOn: false + property bool shareOn: false + property bool preferShare: false + property bool shareAvailable: true + property bool allTraffic: false + property bool allTrafficAvailable: false + property bool editable: true + property int clients: 0 + property bool showPassword: false + property int qrStamp: 0 + property real qrRev: 0 + property bool editing: false + property bool saving: false + property string saveError: "" + property string saveStatus: "" + + function open() { opened = true; showPassword = false; editing = false; saveError = ""; saveStatus = ""; refresh() } + + // Editing the name and password: hotspot-panel.sh set applies them; a + // running hotspot restarts with them. + function startEdit() { + nameField.text = ssid; pwField.text = psk + saveError = ""; saveStatus = ""; editing = true + Qt.callLater(function() { nameField.forceActiveFocus() }) + } + function cancelEdit() { editing = false; saveError = ""; panel.forceActiveFocus() } + function saveEdit() { + var n = nameField.text, p = pwField.text + if (n.length < 1 || n.length > 32) { saveError = "The network name must be 1 to 32 characters."; return } + if (p.length < 8 || p.length > 63) { saveError = "The password must be 8 to 63 characters."; return } + saving = true; saveError = ""; saveStatus = "Saving. A running hotspot restarts with the new values." + setProc.command = ["bash", root.helper, "set", n, p] + setProc.running = true + } + + Process { + id: setProc + stdout: StdioCollector { + waitForEnd: true + onStreamFinished: { + root.saving = false + var t = String(text).trim() + if (t.indexOf("error") === 0) { + root.saveError = t.replace(/^error:\s*/, "") + } else { + root.editing = false + root.showPassword = false + root.saveStatus = t.replace(/^ok:\s*/, "") + panel.forceActiveFocus() + } + root.refresh() + } + } + } + function close() { opened = false } + function refresh() { if (!stateProc.running) stateProc.running = true } + function snapshot() { + return JSON.stringify({ opened: opened, hotspot: hotspotOn, ssid: ssid, vpn: vpnOn, share: shareOn, preferShare: preferShare, clients: clients }) + } + + Process { + id: stateProc + command: ["bash", root.helper, "state"] + stdout: StdioCollector { + waitForEnd: true + onStreamFinished: { + try { + var s = JSON.parse(text) + root.ssid = String(s.ssid || "") + root.psk = String(s.psk || "") + root.vpnOn = s.vpn === "on" + root.shareOn = s.share === "on" + root.preferShare = s.prefer_share === true + root.shareAvailable = s.share_available !== false + root.allTrafficAvailable = s.all_traffic_available === true + root.allTraffic = s.all_traffic === true + root.editable = s.editable !== false + root.clients = Number(s.clients || 0) + var rev = Number(s.qr_rev || 0) + if (root.qrPath !== String(s.qr || "") || rev !== root.qrRev) { root.qrPath = String(s.qr || ""); root.qrRev = rev; root.qrStamp++ } + } catch (e) {} + } + } + } + + Process { + id: shareProc + onExited: root.refresh() + } + + function setShare(on) { + root.preferShare = on + if (!on) root.allTraffic = false + shareProc.command = ["bash", root.helper, "share", on ? "on" : "off"] + shareProc.running = true + } + function setAllTraffic(on) { + root.allTraffic = on + shareProc.command = ["bash", root.helper, "alltraffic", on ? "on" : "off"] + shareProc.running = true + } + + Timer { + running: root.opened + interval: 3000 + repeat: true + onTriggered: root.refresh() + } + + property real reveal: opened ? 1 : 0 + Behavior on reveal { NumberAnimation { duration: 200; easing.type: Easing.OutCubic } } + + PanelWindow { + id: window + + visible: root.opened || root.reveal > 0 + anchors { top: true; bottom: true; left: true; right: true } + exclusionMode: ExclusionMode.Normal + color: "transparent" + WlrLayershell.namespace: "omamobile-hotspot" + WlrLayershell.layer: WlrLayer.Top + WlrLayershell.keyboardFocus: root.opened ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None + + Rectangle { + anchors.fill: parent + color: Commons.Color.menu.scrim + opacity: root.reveal + } + + MouseArea { + anchors.fill: parent + onClicked: root.close() + } + + BorderSurface { + id: panel + + x: Style.gapsOut + width: parent.width - Style.gapsOut * 2 + height: parent.height - Style.gapsOut * 2 + y: Style.gapsOut + Math.round((1 - root.reveal) * Style.space(60)) + opacity: root.reveal + color: Commons.Color.popups.background + borderSpec: Border.surfaceSpec("popups", "border", Commons.Color.popups.border, Math.max(1, Style.space(2))) + radius: Style.cornerRadius + padding: root.pad + + focus: root.opened + Keys.onEscapePressed: root.close() + + MouseArea { anchors.fill: parent } + + Item { + id: body + anchors.fill: parent + anchors.topMargin: panel.contentTopInset + anchors.rightMargin: panel.contentRightInset + anchors.bottomMargin: panel.contentBottomInset + anchors.leftMargin: panel.contentLeftInset + + // ---------- Header: back and title + Item { + id: header + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: root.touchSize + + GlyphButton { + id: back + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + glyph: "󰁍" + onTapped: root.backRequested() + } + + Text { + anchors.left: back.right + anchors.leftMargin: Style.spacing.lg + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: "Hotspot" + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.title + font.bold: true + elide: Text.ElideRight + } + } + + Flickable { + anchors.top: header.bottom + anchors.topMargin: root.pad + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + contentHeight: column.implicitHeight + clip: true + boundsBehavior: Flickable.StopAtBounds + + Column { + id: column + width: parent.width + spacing: Style.spacing.md + + // ---------- The switch + BorderSurface { + width: parent.width + height: Math.max(root.touchSize, switchText.implicitHeight + Style.spacing.lg * 2) + radius: Style.cornerRadius + color: root.hotspotOn ? Util.alpha(Commons.Color.accent, Style.selectedFillAlpha) : Style.normalFillFor(root.foreground, Commons.Color.accent) + borderSpec: Border.controlSpec(root.hotspotOn ? "selected" : "normal", root.foreground, Commons.Color.accent) + + Text { + id: switchGlyph + anchors.left: parent.left + anchors.leftMargin: Style.spacing.lg + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: "󰀂" + color: root.hotspotOn ? Commons.Color.accent : root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.title + } + + Column { + id: switchText + anchors.left: switchGlyph.right + anchors.leftMargin: Style.spacing.lg + anchors.right: switchMark.left + anchors.rightMargin: Style.spacing.md + anchors.verticalCenter: parent.verticalCenter + spacing: Style.spacing.xs + Text { + width: parent.width + textFormat: Text.PlainText + text: root.hotspotOn ? "On" : "Off" + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + } + Text { + width: parent.width + textFormat: Text.PlainText + wrapMode: Text.Wrap + text: root.hotspotOn + ? (root.clients === 1 ? "1 device connected" : root.clients + " devices connected") + ". Shares mobile data only." + : "Shares the phone's mobile data over Wi-Fi." + color: root.foreground + opacity: 0.7 + font.family: Style.font.family + font.pixelSize: Style.font.body + } + } + + Text { + id: switchMark + anchors.right: parent.right + anchors.rightMargin: Style.spacing.lg + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: root.hotspotOn ? "󰔡" : "󰨙" + color: root.hotspotOn ? Commons.Color.accent : root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.title + } + + MouseArea { + anchors.fill: parent + onClicked: root.toggleRequested() + } + } + + // ---------- Name and password; the pencil makes them editable + BorderSurface { + width: parent.width + height: credentials.implicitHeight + Style.spacing.lg * 2 + radius: Style.cornerRadius + color: Style.normalFillFor(root.foreground, Commons.Color.accent) + borderSpec: Border.controlSpec("normal", root.foreground, Commons.Color.accent) + + Column { + id: credentials + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: Style.spacing.lg + spacing: Style.spacing.sm + + Item { + width: parent.width + height: root.touchSize + Text { + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: "Network name" + color: root.foreground + opacity: 0.7 + font.family: Style.font.family + font.pixelSize: Style.font.body + } + GlyphButton { + visible: root.editable + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + glyph: root.editing ? "󰅖" : "󰏫" + foreground: root.foreground + onTapped: root.editing ? root.cancelEdit() : root.startEdit() + } + } + Text { + visible: !root.editing + width: parent.width + textFormat: Text.PlainText + text: root.ssid !== "" ? root.ssid : "–" + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + elide: Text.ElideRight + } + TextField { + id: nameField + visible: root.editing + width: parent.width + height: root.touchSize + verticalAlignment: TextInput.AlignVCenter + font.pixelSize: Style.font.subtitle + foreground: root.foreground + placeholderText: "Network name" + inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase + onTextEdited: root.saveError = "" + Keys.onEscapePressed: root.cancelEdit() + } + Item { width: 1; height: Style.spacing.sm } + Text { + width: parent.width + textFormat: Text.PlainText + text: "Password" + color: root.foreground + opacity: 0.7 + font.family: Style.font.family + font.pixelSize: Style.font.body + } + Item { + width: parent.width + height: root.touchSize + Text { + id: pwText + visible: !root.editing + anchors.left: parent.left + anchors.right: pwEye.left + anchors.rightMargin: Style.spacing.md + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: root.psk === "" ? "–" : (root.showPassword ? root.psk : "••••••••••••") + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + elide: Text.ElideRight + } + TextField { + id: pwField + visible: root.editing + anchors.left: parent.left + anchors.right: pwEye.left + anchors.rightMargin: Style.spacing.md + anchors.top: parent.top + anchors.bottom: parent.bottom + verticalAlignment: TextInput.AlignVCenter + font.pixelSize: Style.font.subtitle + foreground: root.foreground + placeholderText: "Password, 8 to 63 characters" + password: !root.showPassword + inputMethodHints: Qt.ImhSensitiveData | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase + onAccepted: root.saveEdit() + onTextEdited: root.saveError = "" + Keys.onEscapePressed: root.cancelEdit() + } + GlyphButton { + id: pwEye + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + glyph: root.showPassword ? "󰈈" : "󰈉" + foreground: root.foreground + onTapped: root.showPassword = !root.showPassword + } + } + Text { + visible: root.saveError !== "" || root.saveStatus !== "" + width: parent.width + textFormat: Text.PlainText + wrapMode: Text.Wrap + text: root.saveError !== "" ? root.saveError : root.saveStatus + color: root.saveError !== "" ? Commons.Color.urgent : root.foreground + opacity: root.saveError !== "" ? 1 : 0.7 + font.family: Style.font.family + font.pixelSize: Style.font.body + } + Row { + visible: root.editing + width: parent.width + height: visible ? root.touchSize : 0 + spacing: Style.spacing.md + SheetButton { + width: (parent.width - Style.spacing.md) / 2 + label: "Cancel" + foreground: root.foreground + onTapped: root.cancelEdit() + } + SheetButton { + width: (parent.width - Style.spacing.md) / 2 + label: root.saving ? "Saving…" : "Save" + primary: true + enabled: !root.saving + foreground: root.foreground + onTapped: root.saveEdit() + } + } + } + } + + // ---------- QR code: scan to join + BorderSurface { + width: parent.width + height: qrColumn.implicitHeight + Style.spacing.lg * 2 + radius: Style.cornerRadius + color: Style.normalFillFor(root.foreground, Commons.Color.accent) + borderSpec: Border.controlSpec("normal", root.foreground, Commons.Color.accent) + visible: root.qrPath !== "" + + Column { + id: qrColumn + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: Style.spacing.lg + spacing: Style.spacing.sm + + Text { + width: parent.width + textFormat: Text.PlainText + text: "Scan to join" + color: root.foreground + opacity: 0.7 + font.family: Style.font.family + font.pixelSize: Style.font.body + } + Rectangle { + anchors.horizontalCenter: parent.horizontalCenter + width: Math.min(parent.width, Style.space(220)) + height: width + radius: Style.cornerRadius + color: "white" + Image { + anchors.fill: parent + anchors.margins: Style.spacing.md + source: root.qrPath !== "" ? "file://" + root.qrPath + "?" + root.qrStamp : "" + cache: false + smooth: false + fillMode: Image.PreserveAspectFit + } + } + } + } + + // ---------- Share VPN (only where the backend can) + BorderSurface { + id: shareRow + visible: root.shareAvailable + width: parent.width + height: Math.max(root.touchSize, shareText.implicitHeight + Style.spacing.lg * 2) + radius: Style.cornerRadius + color: shareTouch.pressed ? Style.pressedFillFor(root.foreground, Commons.Color.accent) + : root.preferShare ? Util.alpha(Commons.Color.accent, Style.selectedFillAlpha) + : Style.normalFillFor(root.foreground, Commons.Color.accent) + borderSpec: Border.controlSpec(root.preferShare ? "selected" : "normal", root.foreground, Commons.Color.accent) + + Text { + id: shareMark + anchors.left: parent.left + anchors.leftMargin: Style.spacing.lg + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: root.preferShare ? "󰄵" : "󰄱" + color: root.preferShare ? Commons.Color.accent : root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.title + } + + Column { + id: shareText + anchors.left: shareMark.right + anchors.leftMargin: Style.spacing.lg + anchors.right: parent.right + anchors.rightMargin: Style.spacing.lg + anchors.verticalCenter: parent.verticalCenter + spacing: Style.spacing.xs + Text { + width: parent.width + textFormat: Text.PlainText + text: "Share VPN" + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + } + Text { + width: parent.width + textFormat: Text.PlainText + wrapMode: Text.Wrap + text: { + if (!root.preferShare) return "Let devices on this hotspot reach the devices behind your VPN." + if (!root.hotspotOn) return "Applies once the hotspot is on." + if (!root.vpnOn) return "Waiting for the VPN to connect." + if (root.shareOn) return "On. Devices on this hotspot can reach the devices behind your VPN." + return "Turning on…" + } + color: root.foreground + opacity: 0.7 + font.family: Style.font.family + font.pixelSize: Style.font.body + } + } + + MouseArea { + id: shareTouch + anchors.fill: parent + onClicked: root.setShare(!root.preferShare) + } + } + + // ---------- Route all traffic through the VPN (needs Share VPN) + BorderSurface { + id: allRow + visible: root.shareAvailable && root.allTrafficAvailable + width: parent.width + height: Math.max(root.touchSize, allText.implicitHeight + Style.spacing.lg * 2) + radius: Style.cornerRadius + opacity: root.preferShare ? 1 : 0.5 + color: allTouch.pressed ? Style.pressedFillFor(root.foreground, Commons.Color.accent) + : root.allTraffic ? Util.alpha(Commons.Color.accent, Style.selectedFillAlpha) + : Style.normalFillFor(root.foreground, Commons.Color.accent) + borderSpec: Border.controlSpec(root.allTraffic ? "selected" : "normal", root.foreground, Commons.Color.accent) + + Text { + id: allMark + anchors.left: parent.left + anchors.leftMargin: Style.spacing.lg + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: root.allTraffic ? "󰄵" : "󰄱" + color: root.allTraffic ? Commons.Color.accent : root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.title + } + + Column { + id: allText + anchors.left: allMark.right + anchors.leftMargin: Style.spacing.lg + anchors.right: parent.right + anchors.rightMargin: Style.spacing.lg + anchors.verticalCenter: parent.verticalCenter + spacing: Style.spacing.xs + Text { + width: parent.width + textFormat: Text.PlainText + text: "Route all traffic through the VPN" + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + } + Text { + width: parent.width + textFormat: Text.PlainText + wrapMode: Text.Wrap + text: { + if (!root.preferShare) return "Turn on Share VPN first." + if (!root.allTraffic) return "Also send their internet traffic through the VPN. They then appear online with the VPN's address." + if (!root.vpnOn) return "Waiting for the VPN to connect." + return "On. Their internet traffic goes through the VPN." + } + color: root.foreground + opacity: 0.7 + font.family: Style.font.family + font.pixelSize: Style.font.body + } + } + + MouseArea { + id: allTouch + anchors.fill: parent + enabled: root.preferShare + onClicked: root.setAllTraffic(!root.allTraffic) + } + } + } + } + } + } + } +} diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml index 4b2d2f86f..de7be2878 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml @@ -61,7 +61,7 @@ Item { function open(payloadJson) { var payload = {} try { payload = JSON.parse(payloadJson || "{}") || {} } catch (error) {} - if (payload.page === "wifi" || payload.page === "bluetooth") { + if (payload.page === "wifi" || payload.page === "bluetooth" || payload.page === "hotspot") { openPage(payload.page) // Let the host finish delivering this open before it hears a hide. Qt.callLater(root.dismiss) @@ -114,6 +114,7 @@ Item { volume: audio.available ? Math.round(audio.volume * 100) : null, wifiPanel: wifiPicker.opened, bluetoothPanel: bluetoothPanelItem.opened, + hotspotPanel: hotspotPanelItem.opened, notifications: notifications.length, media: media.player ? { app: MediaModel.appName(media.player), title: String(media.player.trackTitle || ""), playing: MediaModel.playing(media.player) } : null @@ -171,6 +172,17 @@ Item { return wifiPicker.snapshot() } + // `openHotspot ''` opens the Hotspot page; `hotspotPanel ''` returns its state. + function openHotspot() { + if (!hotspot.available) return "unavailable" + openHotspotPanel() + return hotspotPanelItem.snapshot() + } + + function hotspotPanel() { + return hotspotPanelItem.snapshot() + } + // `shell call omamobile.quicksettings toggleTile `: the same // action as tapping a tile (any TilesModel id, shown or not). Returns the // new state() or "unknown". @@ -424,16 +436,18 @@ Item { function toggle() { if (available) root.runTileAction("airplane", !enabled) } } - // A Wi-Fi hotspot through NetworkManager. Long-press opens the Wi-Fi panel. + // A Wi-Fi hotspot through NetworkManager. The chevron or a long-press + // opens its page (HotspotPanel.qml): name, password, a QR code to join, + // and the VPN boxes where the hotspot backend has them. QtObject { id: hotspot readonly property bool available: wifi.backendAvailable && !!wifi.device && root.probedHas("hotspot") readonly property bool enabled: available && root.probedOn("hotspot", "hotspot") readonly property string icon: "󰀂" readonly property string status: !available ? "No Wi-Fi radio" : enabled ? "On" : "Off" - readonly property bool longPress: true + readonly property bool details: true function toggle() { if (available) root.runTileAction("hotspot", !enabled) } - function openDetails() { root.openWifiPanel() } + function openDetails() { root.openHotspotPanel() } } // Battery saver: power-profiles-daemon's power-saver profile. @@ -666,14 +680,30 @@ Item { root.dismiss() } + function openHotspotPanel() { + openPage("hotspot") + root.dismiss() + } + // One page at a time. function openPage(page) { if (page !== "wifi") wifiPicker.close() if (page !== "bluetooth") bluetoothPanelItem.close() if (page !== "record") recordPanelItem.close() + if (page !== "hotspot") hotspotPanelItem.close() if (page === "wifi") wifiPicker.open() else if (page === "bluetooth") bluetoothPanelItem.open() else if (page === "record") recordPanelItem.open() + else if (page === "hotspot") hotspotPanelItem.open() + } + + // The page behind the Hotspot tile's chevron; its own window, like the + // Wi-Fi picker. The tile's state drives its switch, so a tap shows at once. + HotspotPanel { + id: hotspotPanelItem + hotspotOn: hotspot.enabled + onBackRequested: root.backToSheet(hotspotPanelItem) + onToggleRequested: hotspot.toggle() } RecordPanel { diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/hotspot-panel.sh b/packages/omamobile-shell/plugins/omamobile.quicksettings/hotspot-panel.sh new file mode 100755 index 000000000..25e5a79d3 --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/hotspot-panel.sh @@ -0,0 +1,123 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Data and actions for the Hotspot page (HotspotPanel.qml), as the session user. +# +# hotspot-panel.sh state one JSON line (see below) +# hotspot-panel.sh set NAME PASS a new network name and password; a running +# hotspot restarts with them. Prints +# "ok: ..." or "error: ..." +# hotspot-panel.sh share on|off "Share VPN": devices on the hotspot reach +# what the phone's VPN reaches +# hotspot-panel.sh alltraffic on|off +# "Route all traffic through the VPN": their +# internet traffic goes through it as well +# +# The state line: {"backend", "hotspot": on|off, "vpn": on|off, +# "share": on|off, "share_available", "prefer_share", +# "all_traffic_available", "all_traffic", "editable", +# "ssid", "psk", "qr": PNG path or "", "qr_rev": a number that changes +# with the picture, "clients": connected devices} +# +# The hotspot itself is NetworkManager's "Hotspot" connection, the one +# tile-action.sh makes with `nmcli device wifi hotspot`: name and password +# come from that connection and change with `nmcli connection modify`. +# NetworkManager's shared mode has no switch for sharing a VPN, so the two +# VPN boxes stay hidden there (share_available false). +# +# A device may bring its own hotspot (its own hostapd, its own firewall) +# and with it the VPN boxes: an executable at /etc/omamobile/hotspot-backend +# (or ~/.config/omamobile/hotspot-backend, for the owner's own) that takes +# the same verbs and prints the same lines replaces everything below; this +# script then only draws the QR code for it. +# +# The QR code is the usual WIFI: string, drawn by qrencode into the runtime +# directory; without qrencode the page shows no code. +set -u +RUN=${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/omamobile-hotspot +QR=$RUN/wifi-qr.png +NM_CON=${OMAMOBILE_HOTSPOT_CONNECTION:-Hotspot} + +json_str() { python3 -c 'import json,sys; print(json.dumps(sys.argv[1]))' "$1"; } + +backend="" +for b in "${XDG_CONFIG_HOME:-$HOME/.config}/omamobile/hotspot-backend" /etc/omamobile/hotspot-backend; do + [[ -x $b ]] && { backend=$b; break; } +done + +# ---- NetworkManager +nm_read() { + ssid=$(nmcli -s -g 802-11-wireless.ssid connection show "$NM_CON" 2>/dev/null) + psk=$(nmcli -s -g 802-11-wireless-security.psk connection show "$NM_CON" 2>/dev/null) +} +nm_active() { nmcli -t -f NAME connection show --active 2>/dev/null | grep -qx "$NM_CON"; } +nm_state() { + nm_read + hotspot=off; nm_active && hotspot=on + vpn=off; nmcli -t -f TYPE connection show --active 2>/dev/null | grep -qE '^(vpn|wireguard)$' && vpn=on + editable=true; [[ -n $ssid ]] || editable=false + clients=0 + if [[ $hotspot == on ]]; then + local dev + dev=$(nmcli -t -f DEVICE,NAME connection show --active 2>/dev/null | awk -F: -v c="$NM_CON" '$2 == c { print $1; exit }') + [[ -n $dev ]] && clients=$(iw dev "$dev" station dump 2>/dev/null | grep -c '^Station') + fi + printf '{"backend":"networkmanager","hotspot":"%s","vpn":"%s","share":"off","share_available":false,"prefer_share":false,"all_traffic_available":false,"all_traffic":false,"editable":%s,"ssid":%s,"psk":%s,"clients":%s}\n' \ + "$hotspot" "$vpn" "$editable" "$(json_str "$ssid")" "$(json_str "$psk")" "${clients:-0}" +} +nm_set() { + if ! nmcli connection modify "$NM_CON" 802-11-wireless.ssid "$1" 802-11-wireless-security.psk "$2" >/dev/null 2>&1; then + echo "error: NetworkManager refused the change"; return + fi + if nm_active; then + nmcli connection up "$NM_CON" >/dev/null 2>&1 && echo "ok: hotspot restarted with the new name and password" || echo "error: the hotspot did not restart" + else + echo "ok: saved; applies when the hotspot is turned on" + fi +} +nm_share() { echo "error: sharing a VPN isn't available with this hotspot"; } + +# ---- the QR code, added to whichever backend answered +# WIFI: strings escape \ ; , : and " +qr_escape() { printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/;/\\;/g' -e 's/,/\\,/g' -e 's/:/\\:/g' -e 's/"/\\"/g'; } +with_qr() { # reads the state line on stdin, prints it with qr and qr_rev + python3 -c ' +import json, os, subprocess, sys +s = json.loads(sys.stdin.readline() or "{}") +run, qr = sys.argv[1], sys.argv[2] +s.setdefault("qr", ""); s.setdefault("qr_rev", 0) +ssid, psk = s.get("ssid") or "", s.get("psk") or "" +def esc(v): return "".join("\\" + c if c in "\\;,:\"" else c for c in v) +want = "WIFI:T:WPA;S:%s;P:%s;;" % (esc(ssid), esc(psk)) +if ssid: + try: + os.makedirs(run, mode=0o700, exist_ok=True) + src = os.path.join(run, "wifi-qr.src") + old = open(src).read() if os.path.exists(src) else None + if old != want or not os.path.exists(qr): + fd = os.open(src, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600); os.write(fd, want.encode()); os.close(fd) + subprocess.run(["qrencode", "-o", qr, "-s", "8", "-m", "2", "-l", "M", want], check=True, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + os.chmod(qr, 0o600) + s["qr"] = qr; s["qr_rev"] = int(os.stat(qr).st_mtime) + except Exception: + s["qr"] = ""; s["qr_rev"] = 0 +print(json.dumps(s))' "$RUN" "$QR" +} + +case ${1:-} in + state) + if [[ -n $backend ]]; then "$backend" state; else nm_state; fi | with_qr + ;; + set) + name=${2:-}; pass=${3:-} + if [[ -z $name || ${#name} -gt 32 ]]; then echo "error: the network name must be 1 to 32 characters"; exit 1; fi + if [[ ${#pass} -lt 8 || ${#pass} -gt 63 ]]; then echo "error: the password must be 8 to 63 characters"; exit 1; fi + if [[ -n $backend ]]; then "$backend" set "$name" "$pass"; else nm_set "$name" "$pass"; fi + rm -f "$QR" + ;; + share|alltraffic) + case ${2:-} in on|off) ;; *) echo "usage: hotspot-panel.sh $1 on|off" >&2; exit 2 ;; esac + if [[ -n $backend ]]; then "$backend" "$1" "$2"; else nm_share; fi + ;; + *) echo "usage: hotspot-panel.sh state | set NAME PASSWORD | share on|off | alltraffic on|off" >&2; exit 2 ;; +esac diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 22301d507..dd017c661 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -344,6 +344,14 @@ sh -n plugins/omamobile.quicksettings/tile-state.sh || fail "tile-state.sh parse sh -n plugins/omamobile.quicksettings/tile-action.sh || fail "tile-action.sh parses" bash test/tile-scripts.sh || fail "quick-settings tile scripts" +# The Hotspot page's script, against fake commands, and the page behind the +# tile's chevron (TilesModel's hotspot tile opens it, like Wi-Fi's picker). +bash -n plugins/omamobile.quicksettings/hotspot-panel.sh || fail "hotspot-panel.sh parses" +bash test/hotspot-panel.sh || fail "hotspot page script" +grep -c 'function openDetails() { root.openHotspotPanel() }' plugins/omamobile.quicksettings/QuickSettings.qml >/dev/null || fail "the Hotspot tile's chevron opens the Hotspot page" +grep -c 'Qt.resolvedUrl("hotspot-panel.sh")' plugins/omamobile.quicksettings/HotspotPanel.qml >/dev/null || fail "the Hotspot page runs the script next to it" +grep -c 'password: !root.showPassword' plugins/omamobile.quicksettings/HotspotPanel.qml >/dev/null || fail "the password field is masked unless shown" + # The Bluetooth pairing helper parses, and its pure parts work without D-Bus. python3 -B -c 'import ast,sys; ast.parse(open(sys.argv[1]).read())' bin/omamobile-bt-agent || fail "omamobile-bt-agent parses" python3 -B test/bt-agent.py || fail "omamobile-bt-agent helpers" diff --git a/packages/omamobile-shell/test/hotspot-panel.sh b/packages/omamobile-shell/test/hotspot-panel.sh new file mode 100755 index 000000000..7435eb53f --- /dev/null +++ b/packages/omamobile-shell/test/hotspot-panel.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Tests for the Hotspot page's script (hotspot-panel.sh) against fake +# commands: the NetworkManager backend's state line, a name and password +# change, the VPN boxes staying off there, the QR code when qrencode is +# there and when it isn't, the checks on a new name and password, and a +# device's own backend taking over. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +script=plugins/omamobile.quicksettings/hotspot-panel.sh +fail() { printf 'not ok - %s\n' "$1" >&2; exit 1; } +pass() { printf 'ok - %s\n' "$1"; } + +tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT +fake=$tmp/bin; basic=$tmp/basic; log=$tmp/log +mkdir -p "$fake" "$basic" "$tmp/home/.config" "$tmp/run" +for tool in bash sh awk sed grep cat head printf python3 rm mkdir; do + ln -s "$(command -v "$tool")" "$basic/$tool" +done +: >"$log" +stub() { printf '#!/bin/sh\n%s\n' "$2" >"$fake/$1"; chmod +x "$fake/$1"; } + +# nmcli: the Hotspot connection with a name and password, active or not +# ($tmp/active), and `connection modify` recorded. +stub nmcli ' +case "$*" in + "-s -g 802-11-wireless.ssid connection show Hotspot") cat '"$tmp"'/ssid ;; + "-s -g 802-11-wireless-security.psk connection show Hotspot") cat '"$tmp"'/psk ;; + "-t -f NAME connection show --active") [ -e '"$tmp"'/active ] && echo Hotspot; echo Home ;; + "-t -f TYPE connection show --active") echo 802-11-wireless ;; + "-t -f DEVICE,NAME connection show --active") [ -e '"$tmp"'/active ] && echo "wlan0:Hotspot" ;; + "connection modify Hotspot 802-11-wireless.ssid "*) echo "nmcli $*" >>'"$log"'; echo "$5" >'"$tmp"'/ssid; echo "$7" >'"$tmp"'/psk ;; + "connection up Hotspot") echo "nmcli $*" >>'"$log"' ;; + *) echo "nmcli: unexpected $*" >&2; exit 1 ;; +esac' +stub iw 'printf "Station aa\nStation bb\n"' +stub qrencode 'echo "qrencode $*" >>'"$log"'; for a in "$@"; do [ "$prev" = -o ] && : >"$a"; prev=$a; done' +echo "Phone" >"$tmp/ssid"; echo "correct horse battery" >"$tmp/psk" + +run() { env -i HOME="$tmp/home" XDG_RUNTIME_DIR="$tmp/run" PATH="$fake:$basic" bash "$script" "$@"; } +field() { python3 -c 'import json,sys; v=json.load(sys.stdin)[sys.argv[1]]; print(v if not isinstance(v,bool) else str(v).lower())' "$1"; } + +# ---- NetworkManager backend, hotspot off +s=$(run state) +[[ $(echo "$s" | field backend) == networkmanager ]] || fail "the backend is NetworkManager" +[[ $(echo "$s" | field hotspot) == off ]] || fail "the hotspot reads off while the connection is down" +[[ $(echo "$s" | field ssid) == Phone ]] || fail "the name comes from the connection" +[[ $(echo "$s" | field psk) == "correct horse battery" ]] || fail "the password comes from the connection" +[[ $(echo "$s" | field share_available) == false ]] || fail "no VPN sharing with NetworkManager's hotspot" +[[ $(echo "$s" | field editable) == true ]] || fail "a connection with a name is editable" +[[ $(echo "$s" | field qr) == "$tmp/run/omamobile-hotspot/wifi-qr.png" ]] || fail "the QR code is drawn into the runtime directory" +grep -q 'WIFI:T:WPA;S:Phone;P:correct horse battery;;' "$log" || fail "the QR code holds the WIFI: string" +[[ $(stat -c %a "$tmp/run/omamobile-hotspot/wifi-qr.src") == 600 ]] || fail "the QR source is private" +n=$(grep -c qrencode "$log"); run state >/dev/null +[[ $(grep -c qrencode "$log") == "$n" ]] || fail "an unchanged code is not drawn again" +pass "hotspot-panel.sh: NetworkManager state, the QR code once" + +# ---- hotspot on: connected devices +: >"$tmp/active" +s=$(run state) +[[ $(echo "$s" | field hotspot) == on && $(echo "$s" | field clients) == 2 ]] || fail "an active hotspot reports its devices" +pass "hotspot-panel.sh: an active hotspot counts its devices" + +# ---- set: the checks, then nmcli modify and a restart of a running hotspot +(run set "" "longenough" || true) | grep -q '^error:' || fail "an empty name is refused" +(run set "Phone" "short" || true) | grep -q '^error:' || fail "a short password is refused" +(run set "$(printf 'x%.0s' $(seq 33))" "longenough" || true) | grep -q '^error:' || fail "a 33-character name is refused" +grep -q 'connection modify' "$log" && fail "nothing is written while a value is refused" +out=$(run set "Cafe" "newpassword1") +echo "$out" | grep -q '^ok: hotspot restarted' || fail "a change on a running hotspot restarts it: $out" +grep -q 'nmcli connection modify Hotspot 802-11-wireless.ssid Cafe 802-11-wireless-security.psk newpassword1' "$log" || fail "the change goes to the connection" +grep -q 'nmcli connection up Hotspot' "$log" || fail "the running hotspot is brought up again" +[[ ! -e $tmp/run/omamobile-hotspot/wifi-qr.png ]] || fail "the old QR code is dropped after a change" +s=$(run state); [[ $(echo "$s" | field ssid) == Cafe ]] || fail "the state shows the new name" +rm "$tmp/active"; : >"$log" +run set "Cafe" "newpassword2" | grep -q '^ok: saved' || fail "a change on a stopped hotspot only saves" +grep -q 'connection up' "$log" && fail "a stopped hotspot is not started by a change" +pass "hotspot-panel.sh: name and password changes" + +# ---- the VPN boxes are refused with NetworkManager +run share on | grep -q '^error:' || fail "Share VPN is refused with NetworkManager's hotspot" +run alltraffic on | grep -q '^error:' || fail "Route all traffic is refused with NetworkManager's hotspot" +pass "hotspot-panel.sh: no VPN boxes with NetworkManager" + +# ---- no qrencode: the page gets no code, everything else as before +rm "$fake/qrencode" +s=$(run state) +[[ $(echo "$s" | field qr) == "" && $(echo "$s" | field ssid) == Cafe ]] || fail "without qrencode the state carries no code" +pass "hotspot-panel.sh: works without qrencode" + +# ---- a device's own backend takes over, the QR code is still added +mkdir -p "$tmp/home/.config/omamobile" +cat >"$tmp/home/.config/omamobile/hotspot-backend" <<'EOF' +#!/bin/sh +echo "backend $*" >>"$LOG" +case $1 in + state) echo '{"backend":"own","hotspot":"on","vpn":"on","share":"on","share_available":true,"prefer_share":true,"all_traffic_available":true,"all_traffic":false,"editable":true,"ssid":"Own","psk":"ownpassword","clients":1}' ;; + set) echo "ok: own set" ;; + share|alltraffic) echo ok ;; +esac +EOF +chmod +x "$tmp/home/.config/omamobile/hotspot-backend" +printf '#!/bin/sh\necho "qrencode $*" >>%s; for a in "$@"; do [ "$prev" = -o ] && : >"$a"; prev=$a; done\n' "$log" >"$fake/qrencode"; chmod +x "$fake/qrencode" +own() { env -i HOME="$tmp/home" XDG_RUNTIME_DIR="$tmp/run" PATH="$fake:$basic" LOG="$log" bash "$script" "$@"; } +s=$(own state) +[[ $(echo "$s" | field backend) == own && $(echo "$s" | field share_available) == true ]] || fail "the device's backend answers the state" +[[ $(echo "$s" | field qr) == "$tmp/run/omamobile-hotspot/wifi-qr.png" ]] || fail "the QR code is added to the backend's state" +grep -q 'S:Own;P:ownpassword' "$log" || fail "the code is drawn from the backend's name and password" +own set "Own" "ownpassword" | grep -q '^ok: own set' || fail "set goes to the device's backend" +own share on | grep -q '^ok' && grep -q 'backend share on' "$log" || fail "share goes to the device's backend" +own alltraffic off | grep -q '^ok' && grep -q 'backend alltraffic off' "$log" || fail "alltraffic goes to the device's backend" +(own set "Own" "short" || true) | grep -q '^error:' || fail "the checks run before any backend" +pass "hotspot-panel.sh: a device's own backend" diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index d08f818d4..924e96608 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.106 +0.2.107 From 7ce88290c2277387fcce68f0685fc8326fc6a5b8 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Mon, 9 Nov 2026 18:36:56 +0100 Subject: [PATCH 2/4] omamobile-shell: Hotspot page review fixes - shareAvailable starts false and only a backend's share_available: true shows the VPN boxes, so they no longer flash on open or stay when the state line can't be parsed. - "Shares mobile data only." is no longer shown for every backend: a backend that knows says where its devices' traffic goes in a new optional uplink_note; NetworkManager's gives none (its devices follow the phone's default route, a full-tunnel VPN included), and the stopped hotspot reads "Shares the phone's internet connection over Wi-Fi." - qrencode gets the WIFI: string on stdin, keeping the password out of /proc/*/cmdline; the unused qr_escape() is gone. - README: a Hotspot page section on hotspot-panel.sh and where a device's hotspot-backend comes from. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-shell/README.md | 4 ++++ .../omamobile.quicksettings/HotspotPanel.qml | 10 ++++++---- .../omamobile.quicksettings/hotspot-panel.sh | 13 ++++++++----- packages/omamobile-shell/test/hotspot-panel.sh | 9 ++++++--- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index b650bc530..ca6da84aa 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -90,6 +90,10 @@ machine: the model comes from a pinned commit of whisper.cpp's model repository with a pinned sha256, and makepkg keeps it in its source cache afterwards. +## Hotspot page + +The page behind the Hotspot tile's chevron talks to `hotspot-panel.sh`. By default that runs NetworkManager's "Hotspot" connection (the one the tile makes with `nmcli device wifi hotspot`): name, password and a QR code to join, and no VPN boxes, since NetworkManager's shared mode has no switch for them; its devices follow the phone's default route. A device that brings its own hotspot (its own hostapd and firewall) installs an executable at `/etc/omamobile/hotspot-backend` from its device package, or the owner puts one at `~/.config/omamobile/hotspot-backend`; it takes the same verbs (`state`, `set NAME PASS`, `share on|off`, `alltraffic on|off`) and prints the same lines, and with it come the VPN boxes and, in `uplink_note`, the sentence on where its devices' traffic goes. No device package ships one yet: the Pixel 9a's is its owner's own for now. + ## File dialogs Open, save and choose-a-folder requests through the portal (Qt, GTK, Electron and Flatpak apps alike) get Nautilus's libadwaita file chooser from xdg-desktop-portal-gnome, not xdg-desktop-portal-gtk's GTK 3 desktop chooser, whose Places sidebar took half of the 480 px width. Nautilus's chooser folds its sidebar away at phone width and has touch-sized rows; `hypr/phone.lua` tiles it, even when it has a parent window, so it fills the screen between the bar and the on-screen keyboard. Only FileChooser goes to the gnome backend: its other interfaces need gnome-shell. It runs without gnome-shell (its Mutter service channel is missing, so it falls back to a plain Wayland connection). xdg-desktop-portal-gtk stays as the fallback and for its other interfaces. GTK apps that would draw their own chooser in-process are sent to the portal too (`GTK_USE_PORTAL=1` for GTK 3, `GDK_DEBUG=portals` for GTK 4, in `environment.d/20-omamobile-osk.conf`); Qt Widgets apps keep Omarchy's `QT_QPA_PLATFORMTHEME=gtk3` for now. diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml index 49bd6d8f6..72f714f9c 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml @@ -35,11 +35,12 @@ Item { property bool vpnOn: false property bool shareOn: false property bool preferShare: false - property bool shareAvailable: true + property bool shareAvailable: false property bool allTraffic: false property bool allTrafficAvailable: false property bool editable: true property int clients: 0 + property string uplinkNote: "" property bool showPassword: false property int qrStamp: 0 property real qrRev: 0 @@ -105,11 +106,12 @@ Item { root.vpnOn = s.vpn === "on" root.shareOn = s.share === "on" root.preferShare = s.prefer_share === true - root.shareAvailable = s.share_available !== false + root.shareAvailable = s.share_available === true root.allTrafficAvailable = s.all_traffic_available === true root.allTraffic = s.all_traffic === true root.editable = s.editable !== false root.clients = Number(s.clients || 0) + root.uplinkNote = String(s.uplink_note || "") var rev = Number(s.qr_rev || 0) if (root.qrPath !== String(s.qr || "") || rev !== root.qrRev) { root.qrPath = String(s.qr || ""); root.qrRev = rev; root.qrStamp++ } } catch (e) {} @@ -280,8 +282,8 @@ Item { textFormat: Text.PlainText wrapMode: Text.Wrap text: root.hotspotOn - ? (root.clients === 1 ? "1 device connected" : root.clients + " devices connected") + ". Shares mobile data only." - : "Shares the phone's mobile data over Wi-Fi." + ? (root.clients === 1 ? "1 device connected" : root.clients + " devices connected") + "." + (root.uplinkNote ? " " + root.uplinkNote : "") + : (root.uplinkNote || "Shares the phone's internet connection over Wi-Fi.") color: root.foreground opacity: 0.7 font.family: Style.font.family diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/hotspot-panel.sh b/packages/omamobile-shell/plugins/omamobile.quicksettings/hotspot-panel.sh index 25e5a79d3..553ff014b 100755 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/hotspot-panel.sh +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/hotspot-panel.sh @@ -16,13 +16,17 @@ # "share": on|off, "share_available", "prefer_share", # "all_traffic_available", "all_traffic", "editable", # "ssid", "psk", "qr": PNG path or "", "qr_rev": a number that changes -# with the picture, "clients": connected devices} +# with the picture, "clients": connected devices, "uplink_note": optional, +# one sentence on where the devices' traffic goes, shown under the +# switch; only a backend that knows says it} # # The hotspot itself is NetworkManager's "Hotspot" connection, the one # tile-action.sh makes with `nmcli device wifi hotspot`: name and password # come from that connection and change with `nmcli connection modify`. # NetworkManager's shared mode has no switch for sharing a VPN, so the two -# VPN boxes stay hidden there (share_available false). +# VPN boxes stay hidden there (share_available false). Its devices follow +# the phone's default route (a full-tunnel VPN included), so it gives no +# uplink_note. # # A device may bring its own hotspot (its own hostapd, its own firewall) # and with it the VPN boxes: an executable at /etc/omamobile/hotspot-backend @@ -77,8 +81,6 @@ nm_set() { nm_share() { echo "error: sharing a VPN isn't available with this hotspot"; } # ---- the QR code, added to whichever backend answered -# WIFI: strings escape \ ; , : and " -qr_escape() { printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/;/\\;/g' -e 's/,/\\,/g' -e 's/:/\\:/g' -e 's/"/\\"/g'; } with_qr() { # reads the state line on stdin, prints it with qr and qr_rev python3 -c ' import json, os, subprocess, sys @@ -95,7 +97,8 @@ if ssid: old = open(src).read() if os.path.exists(src) else None if old != want or not os.path.exists(qr): fd = os.open(src, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600); os.write(fd, want.encode()); os.close(fd) - subprocess.run(["qrencode", "-o", qr, "-s", "8", "-m", "2", "-l", "M", want], check=True, + # the string on stdin, so the password stays out of /proc/*/cmdline + subprocess.run(["qrencode", "-o", qr, "-s", "8", "-m", "2", "-l", "M"], input=want.encode(), check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) os.chmod(qr, 0o600) s["qr"] = qr; s["qr_rev"] = int(os.stat(qr).st_mtime) diff --git a/packages/omamobile-shell/test/hotspot-panel.sh b/packages/omamobile-shell/test/hotspot-panel.sh index 7435eb53f..5de729e90 100755 --- a/packages/omamobile-shell/test/hotspot-panel.sh +++ b/packages/omamobile-shell/test/hotspot-panel.sh @@ -34,7 +34,7 @@ case "$*" in *) echo "nmcli: unexpected $*" >&2; exit 1 ;; esac' stub iw 'printf "Station aa\nStation bb\n"' -stub qrencode 'echo "qrencode $*" >>'"$log"'; for a in "$@"; do [ "$prev" = -o ] && : >"$a"; prev=$a; done' +stub qrencode 'echo "qrencode $* $(cat)" >>'"$log"'; for a in "$@"; do [ "$prev" = -o ] && : >"$a"; prev=$a; done' echo "Phone" >"$tmp/ssid"; echo "correct horse battery" >"$tmp/psk" run() { env -i HOME="$tmp/home" XDG_RUNTIME_DIR="$tmp/run" PATH="$fake:$basic" bash "$script" "$@"; } @@ -50,6 +50,8 @@ s=$(run state) [[ $(echo "$s" | field editable) == true ]] || fail "a connection with a name is editable" [[ $(echo "$s" | field qr) == "$tmp/run/omamobile-hotspot/wifi-qr.png" ]] || fail "the QR code is drawn into the runtime directory" grep -q 'WIFI:T:WPA;S:Phone;P:correct horse battery;;' "$log" || fail "the QR code holds the WIFI: string" +grep -q 'qrencode -o [^ ]* -s 8 -m 2 -l M WIFI:' "$log" || fail "the WIFI: string goes to qrencode on stdin, not as an argument" +[[ $(echo "$s" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("uplink_note", ""))') == "" ]] || fail "NetworkManager's hotspot claims no uplink" [[ $(stat -c %a "$tmp/run/omamobile-hotspot/wifi-qr.src") == 600 ]] || fail "the QR source is private" n=$(grep -c qrencode "$log"); run state >/dev/null [[ $(grep -c qrencode "$log") == "$n" ]] || fail "an unchanged code is not drawn again" @@ -94,18 +96,19 @@ cat >"$tmp/home/.config/omamobile/hotspot-backend" <<'EOF' #!/bin/sh echo "backend $*" >>"$LOG" case $1 in - state) echo '{"backend":"own","hotspot":"on","vpn":"on","share":"on","share_available":true,"prefer_share":true,"all_traffic_available":true,"all_traffic":false,"editable":true,"ssid":"Own","psk":"ownpassword","clients":1}' ;; + state) echo '{"backend":"own","hotspot":"on","vpn":"on","share":"on","share_available":true,"prefer_share":true,"all_traffic_available":true,"all_traffic":false,"editable":true,"ssid":"Own","psk":"ownpassword","clients":1,"uplink_note":"Shares mobile data only."}' ;; set) echo "ok: own set" ;; share|alltraffic) echo ok ;; esac EOF chmod +x "$tmp/home/.config/omamobile/hotspot-backend" -printf '#!/bin/sh\necho "qrencode $*" >>%s; for a in "$@"; do [ "$prev" = -o ] && : >"$a"; prev=$a; done\n' "$log" >"$fake/qrencode"; chmod +x "$fake/qrencode" +printf '#!/bin/sh\necho "qrencode $* $(cat)" >>%s; for a in "$@"; do [ "$prev" = -o ] && : >"$a"; prev=$a; done\n' "$log" >"$fake/qrencode"; chmod +x "$fake/qrencode" own() { env -i HOME="$tmp/home" XDG_RUNTIME_DIR="$tmp/run" PATH="$fake:$basic" LOG="$log" bash "$script" "$@"; } s=$(own state) [[ $(echo "$s" | field backend) == own && $(echo "$s" | field share_available) == true ]] || fail "the device's backend answers the state" [[ $(echo "$s" | field qr) == "$tmp/run/omamobile-hotspot/wifi-qr.png" ]] || fail "the QR code is added to the backend's state" grep -q 'S:Own;P:ownpassword' "$log" || fail "the code is drawn from the backend's name and password" +[[ $(echo "$s" | field uplink_note) == "Shares mobile data only." ]] || fail "the backend's uplink note is passed through" own set "Own" "ownpassword" | grep -q '^ok: own set' || fail "set goes to the device's backend" own share on | grep -q '^ok' && grep -q 'backend share on' "$log" || fail "share goes to the device's backend" own alltraffic off | grep -q '^ok' && grep -q 'backend alltraffic off' "$log" || fail "alltraffic goes to the device's backend" From 7b0b7a74c26b523374d7b40434d45c9dbd9eaca4 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Tue, 10 Nov 2026 08:15:52 +0100 Subject: [PATCH 3/4] omamobile-shell: a swipe up from the bottom edge closes the Hotspot page The owner asked that the full-screen pages behind quick settings' tiles close the same way. The Wi-Fi and Bluetooth pages get a swipe-up strip at their bottom edge in #553; the Hotspot page now has the same one: max(28, Style.space(36)) high, a swipe up past 24 px closes it, and the page's body ends above the strip, so nothing on the page lies under it. test/all on a PC: 304 ok. Co-Authored-By: Claude Opus 5.5 --- .../omamobile.quicksettings/HotspotPanel.qml | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml index 72f714f9c..e4c46199d 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/HotspotPanel.qml @@ -168,6 +168,28 @@ Item { onClicked: root.close() } + // Swipe up from the bottom edge closes the page, as on the Wi-Fi and + // Bluetooth pages: full screen, it covers the dock that takes that swipe + // on the home screen. The page's body ends above the strip, so it never + // lies over the end of the page, where a scroll would close it instead. + Item { + id: swipeStrip + z: 100 + anchors { left: parent.left; right: parent.right; bottom: parent.bottom } + height: Math.max(28, Style.space(36)) + + DragHandler { + target: null + xAxis.enabled: false + property real swipeY: 0 + onActiveTranslationChanged: swipeY = activeTranslation.y + onActiveChanged: { + if (active) swipeY = 0 + else if (swipeY < -24) root.close() + } + } + } + BorderSurface { id: panel @@ -191,7 +213,7 @@ Item { anchors.fill: parent anchors.topMargin: panel.contentTopInset anchors.rightMargin: panel.contentRightInset - anchors.bottomMargin: panel.contentBottomInset + anchors.bottomMargin: Math.max(panel.contentBottomInset, swipeStrip.height) anchors.leftMargin: panel.contentLeftInset // ---------- Header: back and title From b704604c107c83b502048a92c0a4cfaa47b220d8 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Tue, 10 Nov 2026 20:40:57 +0100 Subject: [PATCH 4/4] omamobile-shell: the Hotspot test reads all of a pipe, and its qrencode fake tells arguments from stdin Review of #539. tests/grep-q-pipes (#587) refuses a pipe into grep -q in a script that sets pipefail: grep -q exits at the first match, the writer can get SIGPIPE, and pipefail then fails the pipeline at random. test/hotspot-panel.sh had eleven; they now use grep -c ... >/dev/null, which reads all its input. The fake qrencode logged its arguments and its stdin on one line, so the check that the WIFI: string goes to qrencode on stdin passed either way. It now writes "qrencode args:" and "qrencode stdin:" lines, and the test checks that the string arrives on stdin, that the arguments are only the options, and that the string is never an argument (it would show in /proc/*/cmdline). With the script changed to pass the string as an argument, the old test still passed and the new one fails. Co-Authored-By: Claude Opus 5.5 --- .../omamobile-shell/test/hotspot-panel.sh | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/omamobile-shell/test/hotspot-panel.sh b/packages/omamobile-shell/test/hotspot-panel.sh index 5de729e90..6bbf15d3d 100755 --- a/packages/omamobile-shell/test/hotspot-panel.sh +++ b/packages/omamobile-shell/test/hotspot-panel.sh @@ -34,7 +34,10 @@ case "$*" in *) echo "nmcli: unexpected $*" >&2; exit 1 ;; esac' stub iw 'printf "Station aa\nStation bb\n"' -stub qrencode 'echo "qrencode $* $(cat)" >>'"$log"'; for a in "$@"; do [ "$prev" = -o ] && : >"$a"; prev=$a; done' +# qrencode: its arguments and its stdin on lines of their own, so a check +# can tell which of the two the WIFI: string came on. +qrencode_fake='echo "qrencode args: $*" >>'"$log"'; echo "qrencode stdin: $(cat)" >>'"$log"'; for a in "$@"; do [ "$prev" = -o ] && : >"$a"; prev=$a; done' +stub qrencode "$qrencode_fake" echo "Phone" >"$tmp/ssid"; echo "correct horse battery" >"$tmp/psk" run() { env -i HOME="$tmp/home" XDG_RUNTIME_DIR="$tmp/run" PATH="$fake:$basic" bash "$script" "$@"; } @@ -49,12 +52,13 @@ s=$(run state) [[ $(echo "$s" | field share_available) == false ]] || fail "no VPN sharing with NetworkManager's hotspot" [[ $(echo "$s" | field editable) == true ]] || fail "a connection with a name is editable" [[ $(echo "$s" | field qr) == "$tmp/run/omamobile-hotspot/wifi-qr.png" ]] || fail "the QR code is drawn into the runtime directory" -grep -q 'WIFI:T:WPA;S:Phone;P:correct horse battery;;' "$log" || fail "the QR code holds the WIFI: string" -grep -q 'qrencode -o [^ ]* -s 8 -m 2 -l M WIFI:' "$log" || fail "the WIFI: string goes to qrencode on stdin, not as an argument" +grep -qx 'qrencode stdin: WIFI:T:WPA;S:Phone;P:correct horse battery;;' "$log" || fail "the WIFI: string goes to qrencode on stdin" +grep -qx 'qrencode args: -o [^ ]* -s 8 -m 2 -l M' "$log" || fail "qrencode gets only its options as arguments" +grep -q '^qrencode args: .*WIFI:' "$log" && fail "the WIFI: string is not an argument (it would show in /proc/*/cmdline)" [[ $(echo "$s" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("uplink_note", ""))') == "" ]] || fail "NetworkManager's hotspot claims no uplink" [[ $(stat -c %a "$tmp/run/omamobile-hotspot/wifi-qr.src") == 600 ]] || fail "the QR source is private" -n=$(grep -c qrencode "$log"); run state >/dev/null -[[ $(grep -c qrencode "$log") == "$n" ]] || fail "an unchanged code is not drawn again" +n=$(grep -c '^qrencode args:' "$log"); run state >/dev/null +[[ $(grep -c '^qrencode args:' "$log") == "$n" ]] || fail "an unchanged code is not drawn again" pass "hotspot-panel.sh: NetworkManager state, the QR code once" # ---- hotspot on: connected devices @@ -64,24 +68,24 @@ s=$(run state) pass "hotspot-panel.sh: an active hotspot counts its devices" # ---- set: the checks, then nmcli modify and a restart of a running hotspot -(run set "" "longenough" || true) | grep -q '^error:' || fail "an empty name is refused" -(run set "Phone" "short" || true) | grep -q '^error:' || fail "a short password is refused" -(run set "$(printf 'x%.0s' $(seq 33))" "longenough" || true) | grep -q '^error:' || fail "a 33-character name is refused" +(run set "" "longenough" || true) | grep -c '^error:' >/dev/null || fail "an empty name is refused" +(run set "Phone" "short" || true) | grep -c '^error:' >/dev/null || fail "a short password is refused" +(run set "$(printf 'x%.0s' $(seq 33))" "longenough" || true) | grep -c '^error:' >/dev/null || fail "a 33-character name is refused" grep -q 'connection modify' "$log" && fail "nothing is written while a value is refused" out=$(run set "Cafe" "newpassword1") -echo "$out" | grep -q '^ok: hotspot restarted' || fail "a change on a running hotspot restarts it: $out" +echo "$out" | grep -c '^ok: hotspot restarted' >/dev/null || fail "a change on a running hotspot restarts it: $out" grep -q 'nmcli connection modify Hotspot 802-11-wireless.ssid Cafe 802-11-wireless-security.psk newpassword1' "$log" || fail "the change goes to the connection" grep -q 'nmcli connection up Hotspot' "$log" || fail "the running hotspot is brought up again" [[ ! -e $tmp/run/omamobile-hotspot/wifi-qr.png ]] || fail "the old QR code is dropped after a change" s=$(run state); [[ $(echo "$s" | field ssid) == Cafe ]] || fail "the state shows the new name" rm "$tmp/active"; : >"$log" -run set "Cafe" "newpassword2" | grep -q '^ok: saved' || fail "a change on a stopped hotspot only saves" +run set "Cafe" "newpassword2" | grep -c '^ok: saved' >/dev/null || fail "a change on a stopped hotspot only saves" grep -q 'connection up' "$log" && fail "a stopped hotspot is not started by a change" pass "hotspot-panel.sh: name and password changes" # ---- the VPN boxes are refused with NetworkManager -run share on | grep -q '^error:' || fail "Share VPN is refused with NetworkManager's hotspot" -run alltraffic on | grep -q '^error:' || fail "Route all traffic is refused with NetworkManager's hotspot" +run share on | grep -c '^error:' >/dev/null || fail "Share VPN is refused with NetworkManager's hotspot" +run alltraffic on | grep -c '^error:' >/dev/null || fail "Route all traffic is refused with NetworkManager's hotspot" pass "hotspot-panel.sh: no VPN boxes with NetworkManager" # ---- no qrencode: the page gets no code, everything else as before @@ -102,15 +106,15 @@ case $1 in esac EOF chmod +x "$tmp/home/.config/omamobile/hotspot-backend" -printf '#!/bin/sh\necho "qrencode $* $(cat)" >>%s; for a in "$@"; do [ "$prev" = -o ] && : >"$a"; prev=$a; done\n' "$log" >"$fake/qrencode"; chmod +x "$fake/qrencode" +stub qrencode "$qrencode_fake" own() { env -i HOME="$tmp/home" XDG_RUNTIME_DIR="$tmp/run" PATH="$fake:$basic" LOG="$log" bash "$script" "$@"; } s=$(own state) [[ $(echo "$s" | field backend) == own && $(echo "$s" | field share_available) == true ]] || fail "the device's backend answers the state" [[ $(echo "$s" | field qr) == "$tmp/run/omamobile-hotspot/wifi-qr.png" ]] || fail "the QR code is added to the backend's state" -grep -q 'S:Own;P:ownpassword' "$log" || fail "the code is drawn from the backend's name and password" +grep -q '^qrencode stdin: WIFI:.*S:Own;P:ownpassword' "$log" || fail "the code is drawn from the backend's name and password" [[ $(echo "$s" | field uplink_note) == "Shares mobile data only." ]] || fail "the backend's uplink note is passed through" -own set "Own" "ownpassword" | grep -q '^ok: own set' || fail "set goes to the device's backend" -own share on | grep -q '^ok' && grep -q 'backend share on' "$log" || fail "share goes to the device's backend" -own alltraffic off | grep -q '^ok' && grep -q 'backend alltraffic off' "$log" || fail "alltraffic goes to the device's backend" -(own set "Own" "short" || true) | grep -q '^error:' || fail "the checks run before any backend" +own set "Own" "ownpassword" | grep -c '^ok: own set' >/dev/null || fail "set goes to the device's backend" +own share on | grep -c '^ok' >/dev/null && grep -q 'backend share on' "$log" || fail "share goes to the device's backend" +own alltraffic off | grep -c '^ok' >/dev/null && grep -q 'backend alltraffic off' "$log" || fail "alltraffic goes to the device's backend" +(own set "Own" "short" || true) | grep -c '^error:' >/dev/null || fail "the checks run before any backend" pass "hotspot-panel.sh: a device's own backend"