If you find yourself wondering how to have the name of the network you're connected to on your menu bar, then follow these instructions.
We'll be using an application called hammerspoon, which allows your computer to run lua scripts in the background!
- Go to hammerspoon's github releases and install the latest one. You'll find something like this:
- Click the first choice,
Drag the Hammerspoon application to your Applications
Once in applications, open Hammerspoon with spotlight (press command and space, and type in Hammerspoon, then press enter)
Once Hammerspoon has been opened for the first time, you should see a security prompt:
Launch Hammerspoon at login
Great, now we can add our init script!
Open your terminal and enter,
Now open init.lua, (located at
Paste in the following code:
wifiMenu = hs.menubar.newWithPriority(2147483645) wifiMenu:setTitle(hs.wifi.currentNetwork()) wifiWatcher = nil function ssidChanged() local wifiName = hs.wifi.currentNetwork() if wifiName then wifiMenu:setTitle(wifiName) else wifiMenu:setTitle("Wifi OFF") end end wifiWatcher = hs.wifi.watcher.new(ssidChanged):start()
- Quit hammerspoon using
cmd+q, (not just pressing the red x)
- Reopen hammerspoon
And voila! We now have the name of our network on our menu bar!
Top comments (2)
I've found an issue that shows nothing if the computer was offline at startup. So I modified it like:
Thanks for sharing. It's very useful!
Thanks! I’ll update it when I get a chance