4

Is there a way to turn Wi-Fi on/off using Spotlight, or do I always have to use the mouse and click on the Wi-Fi icon in the taskbar?

Spotlight is pretty powerful, and I would love to have an easy way of enabling/disabling the Wi-Fi connection. Is there a built-in way of doing this, or do I need to create a script for this, and then call the script from Spotlight?

1
  • 1
    You could create a script and use the networksetup command to toggle its state. See -getairportpower and -setairportpower in the manpage for networksetup. – user3439894 Dec 3 '15 at 9:54
6

Not sure if this is the best method, but there's at least one way to set a keyword to trigger stuff in spotlight, and that is by making an application with Automator.

Personally I use Alfred for this type of stuff, but it's not overly difficult to do this with Automator.

  1. Open Automator.app
    • It should by default ask you what type of file to make, but if it doesn't ⌘ + N
  2. Choose a type for your document: Application
  3. Start writing: shell
  4. Press ↵ Enter twice
  5. It should now look something like this enter image description here
  6. Replace the cat text with: networksetup -setairportpower en0 off
  7. Save ( ⌘ + S )
  8. Name it: Wifi OFF.app

  9. Duplicate ( ⌘ + ⇧ + S )

  10. Rename to: Wifi ON
  11. In the networksetup -setairportpower en0 off text, replace the off with: on
  12. Save ( ⌘ + S )

Now if you open spotlight and write wifi, you should see something like this:

enter image description here




If you want to change the icons, here's an article explaining how in detail: http://osxdaily.com/2013/06/04/change-icon-mac/

Short version:

  1. Open the desired image in Preview.app (png works the best)
  2. Select all ( ⌘ + A )
  3. Copy ( ⌘ + C )
  4. Select the Wifi On.app in finder
  5. Go to file info: ( ⌘ + i )
  6. Click the current icon on the top left
  7. Paste ( ⌘ + V )

    After changing the icons, you might not see them change immediately. You can force spotlight to see the new icons faster by trashing the apps and then undoing it (taking files off the trast).

enter image description here

Links to the icons I used:

5
  • This is great - exactly what I was looking for! – nwinkler Dec 3 '15 at 10:22
  • @nwinkler Great :) – Joonas Dec 3 '15 at 10:28
  • Something I forgot to mention. It may be a bit obvious. If you put these app files to dropbox (for example), you can easily use the same keywords on multiple macs. – Joonas Dec 3 '15 at 11:12
  • Good answer! Maybe you can make it into a single 'WiFi toggle' app by first checking if the WiFi is on/off with getairportpower and switching accordingly. – Rob Dec 3 '15 at 11:56
  • Automator has automatically stored the files in iCloud, so they can be accessed on all of my machines - incredibly useful! – nwinkler Dec 3 '15 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .