lua files, and then reference each script from that all-important a file. In this final section, we’re going to create our scripts as separate. We may have pasted our Wi-Fi script over our original ‘Hello from Hammerspoon’ script, but it is possible to run multiple Hammerspoon scripts side by side. Reconnect to your network, and it should trigger another notification, complete with the name of the network that you’ve just connected to. Try disconnecting from your Wi-Fi network, by selecting the ‘Wi-Fi’ icon in your Mac’s menu bar and choosing ‘Turn off Wi-Fi.’ You should see a notification warning you that the Internet is disconnected. Select the ‘Hammerspoon’ icon and choose ‘Reload config.’.Select ‘File > Save’ from your Mac’s menu bar.Hs.notify.show("Connected to Wi-Fi network","",net,"") Hs.notify.show("You lost Wi-Fi connection","","","") In this section, we’re going to create a script that’ll display a notification whenever the Wi-Fi signal is lost, and then displays another notification every time your Mac connects to a new network, complete with the name of the network that it’s just connected to.Ĭopy/paste the following into your a file: wifiwatcher = hs.(function () If you don’t have a reliable Wi-Fi network, or your Mac regularly switches between different networks, then it may help to display notifications about the current state of your Wi-Fi connection. Now we know how to issue a notification, the next step is displaying a notification in response to certain events. Your custom notification should now appear onscreen. Press the ‘Command + h + w’ keys on your keyboard.Select the ‘Hammerspoon’ icon from your Mac’s menu bar and then click ‘Reload Config.’.Select ‘File > Save’ from the menu bar.Let’s start with something simple that you can test straight away, by creating a keyboard shortcut that triggers a notification.Ĭopy/paste the following into the a window: hs.hotkey.bind(, "W", function() Your first Hammerspoon script: Displaying a notification This is where we’ll be creating our first script. Select ‘File > Open Config’ from the Hammerspoon menu bar. ![]() At this point, you should see Hamerspoon’s Lua console.Find the ‘Hammerspoon’ app, and give its accompanying checkbox a click.Click the little padlock in the bottom-left corner, and enter your admin password.Make sure the ‘Privacy’ tab is selected.When prompted, click ‘Open System Preferences.’ This should launch macOS’ regular ‘Security & Privacy’ window.You can select and deselect the various options, depending on your preferences, but you must enable accessibility in order to use Hammerspoon properly, so give the ‘Enable Accessibility’ button a click. The first time you launch Hammerspoon, it’ll present you with a preference pane.Once the file has finished downloading, unzip it and launch the resulting app.Make sure you download the Hammerspoon zip file, rather than the source code! Head over to its GitHub page and download the latest stable release.Of course, this may all be irrelevant with the Magic Toolbar… Copyright © 2003–2022 Kevin Marsh.Let’s start by getting Hammerspoon setup: instead of Brightness, Volume, etc.) I picked F7 through F12 so the markings on the keys matched the functionality. You have to change the Keyboard System Preferences to intrepret the top row as F1, F2, etc. defaultOutputDevice () output : setVolume ( output : volume () + 10 ) end end ) volumeUp () else output = hs.audiodevice. bind (, "f12", function () playing = hs.spotify. ![]() Remap media keys to Spotify-priority equivalents hs.hotkey.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |