Yes — you can collapse Ubuntu's multi-click hotspot flow into a single keystroke. The trick is a small shell script that asks NetworkManager whether a connection named Hotspot is running: if it is, the script switches the Wi-Fi radio off; if not, it runs nmcli device wifi hotspot, which turns the radio into an access point and shares whatever the machine is connected to — your wired Ethernet. Save the script in ~/.local/bin and bind it to a spare combination such as Super+H.
What the built-in hotspot actually does
When you click "Use as Hotspot" in GNOME's network settings, nothing mysterious happens. NetworkManager creates a connection profile literally named Hotspot, puts your Wi-Fi card into access-point (AP) mode, and enables network address translation so connected phones and tablets ride out through the laptop's other active connection — the Ethernet port in your case.
Two consequences matter for automating it:
- Because the profile has a fixed name, a script can detect the hotspot's state simply by checking whether a connection called
Hotspotis active. - While the hotspot runs, the same radio is busy acting as an access point, so the laptop itself cannot stay joined to a Wi-Fi network. Your wired link is unaffected.
The toggle script
The logic is a two-way switch. First find the Wi-Fi device, then inspect the active connections: if Hotspot appears among them, disconnect the radio; otherwise start the hotspot.
#!/bin/bash
IFACE=$(nmcli -t -f DEVICE,TYPE device | grep ':wifi' | cut -d: -f1 | head -n 1)
if nmcli connection show --active | grep -q "Hotspot"; then
nmcli device disconnect "$IFACE"
else
nmcli device wifi hotspot
fi
The first line asks nmcli for a terse device list, filters for the Wi-Fi type, and keeps the first match. The if line greps the active connection list for the hotspot profile. Running the script twice therefore returns you to where you started — on when it was off, off when it was on. (As an alternative to disconnecting the device, nmcli connection down Hotspot shuts the profile down directly and works just as well.)
Install, test, and bind a key
Create the file, paste the script, and make it executable:
mkdir -p ~/.local/bin
nano ~/.local/bin/hotspot-toggle.sh # paste the script here
chmod 700 ~/.local/bin/hotspot-toggle.sh
Run it once from a terminal — ~/.local/bin/hotspot-toggle.sh — and confirm the hotspot appears in the network menu and your phone can connect. Run it again and confirm everything shuts down. The chmod 700 keeps the file private to your user, which matters because the script changes network state.
Now bind it. In GNOME open Settings → Keyboard, go to View and Customize Shortcuts, and choose Custom Shortcuts. Add a new entry, name it something like "Toggle hotspot", and set the command to the absolute path:
/home/yourname/.local/bin/hotspot-toggle.sh
Then click "Set Shortcut" and press Super+H or any free combination. Use the absolute path rather than ~: shortcut commands are not launched through a login shell, so tilde expansion is not guaranteed.
Choosing your own SSID and password
Out of the box the network is named Hotspot with an automatically generated password. You can set your own the first time you start it:
nmcli device wifi hotspot ssid "apartment-net" password "a-long-passphrase"
The profile remembers these values, so later invocations of the plain command reuse them. The password must be 8–63 characters to satisfy WPA2. To change it later without restarting the hotspot, edit the profile directly with nmcli connection modify Hotspot 802-11-wireless-security.psk "new-passphrase".
Caveats worth knowing
- AP mode support. Nearly all laptop Wi-Fi cards can act as access points, but verify with
iw list | grep -A 12 "Supported interface modes"— anAPentry must appear. - Something must be shared. The hotspot routes through the machine's current active connection. If Ethernet drops, clients may stay associated to the hotspot but lose the internet.
- Your own Wi-Fi link drops. One radio cannot be a client and an access point at the same time on typical hardware.
- Suspend stops it. NetworkManager tears the hotspot down when the machine sleeps; press the shortcut again after waking.
- Renamed profiles. If you ever rename the hotspot connection, update the
grepstring in the script to match.
Frequently Asked Questions
Does this work outside GNOME?
The script only needs NetworkManager and nmcli, so it runs on any desktop — or even over SSH. Only the keyboard-binding steps are GNOME-specific; other desktop environments have equivalent custom-shortcut settings.
Is the hotspot secure?
It uses WPA2 with the profile's password, so treat it like any home Wi-Fi network: pick a long passphrase and switch it off when you don't need it — one press of your shortcut.
Can I start the hotspot without logging into the desktop?
Yes. Run the script from a TTY or over SSH; it manipulates NetworkManager directly, so no graphical session is required.
Why does my phone connect but get no internet?
The hotspot shares the machine's active connection. Confirm Ethernet is up with nmcli device status. NetworkManager normally handles NAT and forwarding automatically when the hotspot starts, so a dead uplink is the usual culprit.
Can I trigger it with a mouse button instead of a key?
Yes. Anything that can execute a command — mouse-button configuration tools, a desktop launcher, or a panel button — can call the same script path.
Will the hotspot survive a reboot?
NetworkManager may auto-start the profile depending on your settings, but the script itself is stateless: whatever the current state, one press flips it. If you want it always on at login, add the script to your startup applications.