Configuring your mac to display the wifi name on the menu bar

mcrowder65 profile image Matt Crowder ・2 min read

a picture of a mac menu bar with network name attached

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!

picture of the hammerspoon releases on github

  • Click the first choice, Hammerspoon-0.9.73.zip
  • Once downloaded, unarchive the zip to your Downloads
    a picture of mac finder showing the downloads of hammerspoon

  • 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:
    image of accepting hammerspoon security prompt

  • Click Open

  • Check Launch Hammerspoon at login

  • Great, now we can add our init script!

  • Open your terminal and enter, touch ~/.hammerspoon/init.lua,

  • Now open init.lua, (located at ~/.hammerspoon/init.lua)

  • Paste in the following code:

wifiMenu = hs.menubar.newWithPriority(2147483645)

wifiWatcher = nil

function ssidChanged()
    local wifiName = hs.wifi.currentNetwork()
    if wifiName then
        wifiMenu:setTitle("Wifi OFF")

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!

Posted on by:

mcrowder65 profile

Matt Crowder


Software Engineer at Appian, previously at Walmart Labs. Co-organizer of novajavascript.com, public speaker, teacher, codementor.io/mcrowder65


markdown guide

I've found an issue that shows nothing if the computer was offline at startup. So I modified it like:

wifiNameApp:setTitle(hs.wifi.currentNetwork() or "Offline")   

Thanks for sharing. It's very useful!


Thanks! I’ll update it when I get a chance