From 168861dbb365098e4a2df6ea0042ed637e6384f6 Mon Sep 17 00:00:00 2001 From: Cleboost Date: Thu, 13 Aug 2026 11:13:20 +0200 Subject: [PATCH] feat(hotspot): add Control Center shortcut to toggle hotspot Closes #349 by exposing a cc-toggle shortcut entry that mirrors service state and sends the existing hotspot_command toggle action. --- hotspot/README.md | 8 ++++---- hotspot/plugin.toml | 10 +++++++--- hotspot/shortcut.luau | 35 +++++++++++++++++++++++++++++++++++ hotspot/translations/en.json | 4 ++++ 4 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 hotspot/shortcut.luau diff --git a/hotspot/README.md b/hotspot/README.md index b801d42..20d1933 100644 --- a/hotspot/README.md +++ b/hotspot/README.md @@ -8,7 +8,7 @@ devices in a panel, and control the service over IPC. | Field | Value | | --- | --- | | ID | `cleboost/hotspot` | -| Entries | Bar widget: `toggle`; panel: `panel`; service: `hotspot` | +| Entries | Bar widget: `toggle`; shortcut: `cc-toggle`; panel: `panel`; service: `hotspot` | ## Requirements @@ -19,9 +19,9 @@ Install `nmcli` from NetworkManager, plus `iw` and `ip` from iproute2, on ## Usage 1. Open the plugin settings and set the hotspot name and password. -2. Add the `toggle` widget to a bar. -3. Left-click the widget to open the panel with the connected device list. -4. Right-click the widget to start or stop the hotspot. +2. Add the `toggle` widget to a bar and/or the `cc-toggle` shortcut in Settings → Control Center. +3. Left-click the bar widget to open the panel with the connected device list. +4. Right-click the bar widget, or click the Control Center shortcut, to start or stop the hotspot. ```sh noctalia msg panel-toggle cleboost/hotspot:panel diff --git a/hotspot/plugin.toml b/hotspot/plugin.toml index f501c3c..a6d0f6c 100644 --- a/hotspot/plugin.toml +++ b/hotspot/plugin.toml @@ -1,12 +1,12 @@ id = "cleboost/hotspot" name = "Wi-Fi Hotspot" -version = "1.0.0" +version = "1.1.0" plugin_api = 9 author = "Cleboost" license = "MIT" icon = "router" -description = "Start and stop a Wi-Fi hotspot from the bar, with connected device list and IPC control." -tags = ["network", "bar", "panel", "service", "utility", "system", "indicator"] +description = "Start and stop a Wi-Fi hotspot from the bar or Control Center, with connected device list and IPC control." +tags = ["network", "bar", "panel", "service", "shortcut", "utility", "system", "indicator"] dependencies = ["nmcli", "iw", "ip"] [[setting]] @@ -53,6 +53,10 @@ entry = "widget.luau" label_key = "settings.glyph.label" default = "router" +[[shortcut]] +id = "cc-toggle" +entry = "shortcut.luau" + [[panel]] id = "panel" entry = "panel.luau" diff --git a/hotspot/shortcut.luau b/hotspot/shortcut.luau new file mode 100644 index 0000000..247ed13 --- /dev/null +++ b/hotspot/shortcut.luau @@ -0,0 +1,35 @@ +--!nonstrict + +local COMMAND_KEY = "hotspot_command" + +local status = noctalia.state.get("hotspot_status") or { + active = false, + busy = false, + available = true, +} + +local function sendCommand(action) + noctalia.state.set(COMMAND_KEY, { action = action }) +end + +local function render() + local active = status.active == true + shortcut.setLabel(if active then noctalia.tr("shortcut.active") else noctalia.tr("shortcut.inactive")) + shortcut.setIcon("router", "wifi-off") + shortcut.setActive(active) + shortcut.setEnabled(status.available ~= false and status.busy ~= true) +end + +noctalia.state.watch("hotspot_status", function(value) + if type(value) == "table" then + status = value + render() + end +end) + +render() + +function onClick() + if status.available == false or status.busy == true then return end + sendCommand("toggle") +end diff --git a/hotspot/translations/en.json b/hotspot/translations/en.json index 55a19ef..d4347d8 100644 --- a/hotspot/translations/en.json +++ b/hotspot/translations/en.json @@ -44,6 +44,10 @@ "stopping_title": "Stopping" } }, + "shortcut": { + "active": "Hotspot on", + "inactive": "Hotspot off" + }, "settings": { "glyph": { "label": "Bar glyph"