I didn’t know the answer to your question either, but I got curious and looked into the code of Gnome Settings Manager, which is the actual name for the Settings app. Turns out that the code for the hotspot UI is entirely in cc-wifi-hotspot-dialog.c
. The part where the action happens seems to be inside the cc_wifi_hotspot_dialog_response
function.
That function is for handling the UI response to hitting a button in the hotspot dialog. If you hit the Turn On button, the UI code talks to the NetworkManager client library, telling it to make stuff happen.
So the code itself doesn’t give us a simple CLI invocation that we could copy and paste. However, NetworkManager comes with a CLI tool, nmcli
, which comes pre-installed on the Librem 5 and which should cover most of NetworkManager’s feature set.
One way to toggle the hotspot in the CLI would be: look at the calls to NetworkManager one by one and try to replicate that via nmcli
calls.
However, there’s still an easier way. Note that the UI handler code creates a NetworkManager connection named Hotspot
but never bothers to delete that connection. Instead, it leaves the connection persistent, even after you’ve stopped the hotspot. You can confirm that by stopping your hotspot and then running nmcli connection show
. Its output should include an entry that says Hotspot
.
Let’s piggy-back on that: configure your hotspot just once via Settings, and turn it on once and then off again. From now on, you can turn on the hotspot by running a single CLI command:
sudo nmcli connection up Hotspot
After a few seconds, the hotspot should be active.
To turn off the hotspot, run:
sudo nmcli connection down Hotspot
Let me know if that helps.