Toggle Wifi Enabled - Hammerspoon

Toggle the wifi on and off with a keyboard shortcut using Hammerspoon:

function toggleWifiEnabled()
    return function()
        print('toggleWifiEnabled')
        if hs.network.interfaceDetails() == nil then
            print('network is off')
            hs.wifi.setPower(true)
            print('network turned on')
        else
            print('network is on')
            hs.wifi.setPower(false)
            print('network turned off')
        end
    end
end
hs.hotkey.bind({'option'}, 'w', toggleWifiEnabled())
View this page on GitHub.
Posted .

Comments

Leave a Reply