Skip to content

Commit dd2f434

Browse files
dhhclaude
andcommitted
Extract the speed test into its own omarchy.speedtest panel plugin
The network panel now summons it, so a clone or a third-party plugin declaring clonedFrom: omarchy.speedtest can replace the whole speed test -- dials and run orchestration alike -- for every caller. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 4519451 commit dd2f434

5 files changed

Lines changed: 302 additions & 274 deletions

File tree

‎default/omarchy/omarchy-menu.jsonc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"setup.network.dns.google": {"icon":"󰊭","label":"Google","checked":"[[ \"$(omarchy-dns)\" == \"Google\" ]]","action":"omarchy-dns Google"},
119119
"setup.network.dns.custom": {"icon":"","label":"Custom","checked":"[[ \"$(omarchy-dns)\" == \"Custom\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-dns Custom'"},
120120
"setup.network.qr": {"icon":"󰐲","label":"QR Code","aliases":["wifi-qr"],"when":"[[ $(omarchy-network-status) == wifi* ]]","action":"omarchy-shell omarchy.network showQr"},
121-
"setup.network.speedtest": {"icon":"󰓅","label":"Speed Test","aliases":["speedtest","speed-test"],"action":"omarchy-shell omarchy.network speedTest"},
121+
"setup.network.speedtest": {"icon":"󰓅","label":"Speed Test","aliases":["speedtest","speed-test"],"action":"omarchy-shell shell summon omarchy.speedtest"},
122122
"setup.default": {"icon":"","label":"Defaults","aliases":["default","defaults"]},
123123
"setup.default.agent": {"icon":"󰚩","label":"Agent"},
124124
"setup.default.agent.claude": {"icon":"󰛄","label":"Claude","checked":"[[ \"$(omarchy-default-agent)\" == \"claude\" ]]","action":"omarchy-default-agent claude"},

‎shell/plugins/panels/network/Panel.qml‎

Lines changed: 17 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Panel {
1717
manageIpc: false
1818

1919
// Centralized close so callers can't forget to drop the passphrase prompt.
20-
readonly property bool overlayVisible: qrVisible || speedTestModalOpen
20+
readonly property bool overlayVisible: qrVisible
2121

2222
// Shadows the base open(): a summon or toggle while a centered card is up
2323
// dismisses the card instead of opening the compact panel behind an
@@ -26,7 +26,6 @@ Panel {
2626
function open() {
2727
if (overlayVisible) {
2828
hideWifiQr()
29-
hideSpeedTest()
3029
return
3130
}
3231
root.controller.show()
@@ -35,10 +34,9 @@ Panel {
3534
function close() {
3635
root.controller.hide()
3736
cancelPasswordPrompt()
38-
// The centered cards outlive the compact panel, but the widget's
39-
// canonical close must not leave an overlay (or its traffic) behind.
37+
// The centered card outlives the compact panel, but the widget's
38+
// canonical close must not leave an overlay behind.
4039
hideWifiQr()
41-
hideSpeedTest()
4240
}
4341

4442
function cancelPasswordPrompt() {
@@ -101,15 +99,6 @@ Panel {
10199
property string bandSelected: "auto"
102100
property var bandAvailable: []
103101
property string pendingBand: ""
104-
property bool speedTestRunning: false
105-
property bool speedTestModalOpen: false
106-
property bool speedTestExpectedStop: false
107-
property bool pendingSpeedRun: false
108-
property string speedTestPhase: ""
109-
property string speedTestStderr: ""
110-
property string speedTestDownloadMbps: ""
111-
property string speedTestUploadMbps: ""
112-
property string speedTestError: ""
113102

114103
// Per-row in-flight state. `actionSsid` flips on for the row whose action
115104
// is currently running so it can render "Connecting…" / "Disconnecting…" /
@@ -251,15 +240,12 @@ Panel {
251240
root.refresh()
252241
root.showWifiQr(true)
253242
}
254-
function speedTest() {
255-
root.refresh()
256-
root.showSpeedTest()
257-
}
243+
function speedTest() { root.summonSpeedTest() }
258244
}
259245

260246
function activateHeader() {
261247
if (headerIndex === qrHeaderIndex) showWifiQr()
262-
else if (headerIndex === speedHeaderIndex) showSpeedTest()
248+
else if (headerIndex === speedHeaderIndex) summonSpeedTest()
263249
else if (headerIndex === toggleHeaderIndex) toggleNetwork()
264250
}
265251

@@ -691,83 +677,17 @@ Panel {
691677
actionProc.running = true
692678
}
693679

694-
function updateSpeedTestLine(line) {
695-
var value = parseFloat(line)
696-
if (!isFinite(value) || value < 0) return
697-
698-
if (speedTestPhase === "down") speedTestDownloadMbps = String(value)
699-
else if (speedTestPhase === "up") speedTestUploadMbps = String(value)
700-
speedTestError = ""
701-
}
702-
703-
// The speed test lives in a centered modal card like the QR share.
704-
// Opening it starts a fresh run; dismissing it stops the traffic, so the
705-
// download workers never keep saturating the link behind a closed card.
706-
function showSpeedTest() {
707-
if (!speedTestModalOpen) {
708-
speedTestModalOpen = true
709-
controller.hide()
710-
cancelPasswordPrompt()
711-
}
712-
runSpeedTest()
713-
}
714-
715-
function hideSpeedTest() {
716-
speedTestModalOpen = false
717-
pendingSpeedRun = false
718-
speedTestPhaseTimer.stop()
719-
// Clear the phase before killing the process: onExited advances to the
720-
// upload phase when it still reads "down".
721-
speedTestPhase = ""
722-
speedTestRunning = false
723-
if (speedTestProc.running) {
724-
speedTestExpectedStop = true
725-
speedTestProc.running = false
726-
}
727-
}
728-
729-
function runSpeedTest() {
730-
if (speedTestProc.running) {
731-
// A dismissal's SIGTERM is still in flight; Process.running stays true
732-
// until the child exits, so queue the fresh run for onExited.
733-
if (speedTestExpectedStop) pendingSpeedRun = true
734-
return
735-
}
736-
speedTestError = ""
737-
speedTestDownloadMbps = ""
738-
speedTestUploadMbps = ""
739-
speedTestRunning = true
740-
startSpeedTestPhase("down")
741-
}
742-
743-
function startSpeedTestPhase(phase) {
744-
speedTestExpectedStop = false
745-
speedTestPhase = phase
746-
speedTestStderr = ""
747-
speedTestProc.command = ["omarchy-network-speedtest", phase]
748-
speedTestProc.running = true
749-
speedTestPhaseTimer.restart()
750-
}
751-
752-
function stopSpeedTestPhase() {
753-
speedTestPhaseTimer.stop()
754-
if (speedTestProc.running) {
755-
speedTestExpectedStop = true
756-
speedTestProc.running = false
757-
return
758-
}
759-
finishSpeedTestPhase()
760-
}
761-
762-
function finishSpeedTestPhase() {
763-
if (speedTestPhase === "down") {
764-
startSpeedTestPhase("up")
765-
return
766-
}
767-
768-
speedTestPhase = ""
769-
speedTestRunning = false
770-
speedTestExpectedStop = false
680+
// The speed test is its own panel plugin (omarchy.speedtest) so a
681+
// replacement design can take it over; summon() routes to whichever
682+
// implementation is enabled. The payload names the connection when this
683+
// panel knows it; the plugin looks it up itself otherwise.
684+
function summonSpeedTest() {
685+
controller.hide()
686+
cancelPasswordPrompt()
687+
var connection = ""
688+
if (info.type === "wifi") connection = info.ssid || "Wi-Fi"
689+
else if (info.type === "ethernet") connection = "Ethernet"
690+
bar.shell.summon("omarchy.speedtest", connection ? JSON.stringify({ connection: connection }) : "{}")
771691
}
772692

773693
function dnsCommand(provider) {
@@ -1017,42 +937,6 @@ Panel {
1017937
}
1018938
}
1019939

1020-
Process {
1021-
id: speedTestProc
1022-
stdout: SplitParser { onRead: function(line) { root.updateSpeedTestLine(line) } }
1023-
stderr: StdioCollector {
1024-
waitForEnd: true
1025-
onStreamFinished: root.speedTestStderr = String(text || "").trim()
1026-
}
1027-
onExited: function(exitCode) {
1028-
speedTestPhaseTimer.stop()
1029-
1030-
if (root.pendingSpeedRun) {
1031-
root.pendingSpeedRun = false
1032-
root.speedTestExpectedStop = false
1033-
if (root.speedTestModalOpen) Qt.callLater(root.runSpeedTest)
1034-
return
1035-
}
1036-
1037-
if (!root.speedTestExpectedStop && exitCode !== 0) {
1038-
root.speedTestError = root.speedTestStderr || "Speed test failed"
1039-
root.speedTestPhase = ""
1040-
root.speedTestRunning = false
1041-
return
1042-
}
1043-
1044-
root.speedTestExpectedStop = false
1045-
root.finishSpeedTestPhase()
1046-
}
1047-
}
1048-
1049-
Timer {
1050-
id: speedTestPhaseTimer
1051-
interval: 5000
1052-
repeat: false
1053-
onTriggered: root.stopSpeedTestPhase()
1054-
}
1055-
1056940
// Action runner for DNS provider changes. Wi-Fi actions use the
1057941
// Quickshell.Networking NetworkManager backend directly.
1058942
Process {
@@ -1316,7 +1200,7 @@ Panel {
13161200
hasCursor: root.speedHeaderHasCursor
13171201
Layout.alignment: Qt.AlignVCenter
13181202
onHovered: function(on) { if (on) root.setHeaderCursor(root.speedHeaderIndex) }
1319-
onClicked: root.showSpeedTest()
1203+
onClicked: root.summonSpeedTest()
13201204
}
13211205

13221206
ToggleSwitch {
@@ -1720,24 +1604,6 @@ Panel {
17201604
onPasswordToggleRequested: root.toggleQrPassword()
17211605
}
17221606

1723-
SpeedTestPanel {
1724-
anchorItem: button
1725-
bar: root.bar
1726-
running: root.speedTestRunning
1727-
phase: root.speedTestPhase
1728-
downloadMbps: root.speedTestDownloadMbps
1729-
uploadMbps: root.speedTestUploadMbps
1730-
error: root.speedTestError
1731-
connectionName: {
1732-
if (root.info.type === "wifi") return root.info.ssid || "Wi-Fi"
1733-
if (root.info.type === "ethernet") return "Ethernet"
1734-
return ""
1735-
}
1736-
open: root.speedTestModalOpen
1737-
onCloseRequested: root.hideSpeedTest()
1738-
onRunAgainRequested: root.runSpeedTest()
1739-
}
1740-
17411607
// One Wi-Fi band pill. `active` (fill) is the band actually in use and
17421608
// `selected` (bold) is the pinned choice; with Automatic on nothing is
17431609
// pinned, so only the live band lights up and the two can no longer read as

‎shell/plugins/panels/network/manifest.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "Network",
55
"version": "1.0.0",
66
"author": "Omarchy",
7-
"description": "Wi-Fi list, connection state, QR sharing, and speed test",
7+
"description": "Wi-Fi list, connection state, and QR sharing",
88
"kinds": [
99
"bar-widget"
1010
],
@@ -13,7 +13,7 @@
1313
},
1414
"barWidget": {
1515
"displayName": "Network",
16-
"description": "Wi-Fi list, connection state, QR sharing, and speed test",
16+
"description": "Wi-Fi list, connection state, and QR sharing",
1717
"category": "Network",
1818
"allowMultiple": false
1919
}

0 commit comments

Comments
 (0)