Merge pull request #350 from Cleboost/feat/hotspot-control-center-shortcut
feat(hotspot): add Control Center shortcut to toggle hotspot
This commit is contained in:
+4
-4
@@ -8,7 +8,7 @@ devices in a panel, and control the service over IPC.
|
|||||||
| Field | Value |
|
| Field | Value |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| ID | `cleboost/hotspot` |
|
| ID | `cleboost/hotspot` |
|
||||||
| Entries | Bar widget: `toggle`; panel: `panel`; service: `hotspot` |
|
| Entries | Bar widget: `toggle`; shortcut: `cc-toggle`; panel: `panel`; service: `hotspot` |
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -19,9 +19,9 @@ Install `nmcli` from NetworkManager, plus `iw` and `ip` from iproute2, on
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
1. Open the plugin settings and set the hotspot name and password.
|
1. Open the plugin settings and set the hotspot name and password.
|
||||||
2. Add the `toggle` widget to a bar.
|
2. Add the `toggle` widget to a bar and/or the `cc-toggle` shortcut in Settings → Control Center.
|
||||||
3. Left-click the widget to open the panel with the connected device list.
|
3. Left-click the bar widget to open the panel with the connected device list.
|
||||||
4. Right-click the widget to start or stop the hotspot.
|
4. Right-click the bar widget, or click the Control Center shortcut, to start or stop the hotspot.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
noctalia msg panel-toggle cleboost/hotspot:panel
|
noctalia msg panel-toggle cleboost/hotspot:panel
|
||||||
|
|||||||
+7
-3
@@ -1,12 +1,12 @@
|
|||||||
id = "cleboost/hotspot"
|
id = "cleboost/hotspot"
|
||||||
name = "Wi-Fi Hotspot"
|
name = "Wi-Fi Hotspot"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
plugin_api = 9
|
plugin_api = 9
|
||||||
author = "Cleboost"
|
author = "Cleboost"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
icon = "router"
|
icon = "router"
|
||||||
description = "Start and stop a Wi-Fi hotspot from the bar, with connected device list and IPC control."
|
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", "utility", "system", "indicator"]
|
tags = ["network", "bar", "panel", "service", "shortcut", "utility", "system", "indicator"]
|
||||||
dependencies = ["nmcli", "iw", "ip"]
|
dependencies = ["nmcli", "iw", "ip"]
|
||||||
|
|
||||||
[[setting]]
|
[[setting]]
|
||||||
@@ -53,6 +53,10 @@ entry = "widget.luau"
|
|||||||
label_key = "settings.glyph.label"
|
label_key = "settings.glyph.label"
|
||||||
default = "router"
|
default = "router"
|
||||||
|
|
||||||
|
[[shortcut]]
|
||||||
|
id = "cc-toggle"
|
||||||
|
entry = "shortcut.luau"
|
||||||
|
|
||||||
[[panel]]
|
[[panel]]
|
||||||
id = "panel"
|
id = "panel"
|
||||||
entry = "panel.luau"
|
entry = "panel.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
|
||||||
@@ -44,6 +44,10 @@
|
|||||||
"stopping_title": "Stopping"
|
"stopping_title": "Stopping"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"shortcut": {
|
||||||
|
"active": "Hotspot on",
|
||||||
|
"inactive": "Hotspot off"
|
||||||
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"glyph": {
|
"glyph": {
|
||||||
"label": "Bar glyph"
|
"label": "Bar glyph"
|
||||||
|
|||||||
Reference in New Issue
Block a user