Hammerspoon program series of keystrokes11/21/2023 I use a as the "entry point" for nearly all my Hammerspoon based automation. My most common use of a is to launch an application, so I have a table of applications that I can define a "hyper key" for, and optionally some local bindings that I bind inside that application to use globally. hyper : bind (, 'r', nil, function () hs. Press `HYPER+r`, get the Hammerspoon console. Because your "hyper key" is not a cluster of modifier keys, you can actually use it in conjunction with any normal modifiers. One big advantage to using Hammerspoon as a "man-in-the-middle" is using modifiers with your hyper key. Brett Terpstra first wrote about this in "A Useful Caps Lock Key" in 2012. In this as in all things, I am not the first. Instead of having every single application listening to all the keystrokes, I can control it one place. I use a single often-unused key (in my case, F19) to trigger a hs.hotkey.modal in Hammerspoon. In my case, Hammerspoon becomes a single "router" to all the automation and UI customization on my Mac. Using a single keycode as your "hyper" key, and handling the translation at the automation layer is much more expressive. Because of this a lot of hyper key setups are limited to "leader key" style interactions. Using the "hyper chord" as the entire "hyper key", you can't add any more modifiers, because it is already all the modifiers. While it works well, it has its limitations. You can absolutely do this in Hammerspoon if you want. The user would then use some kind of automation software like Alfred or Keyboard Maestro to listen for the "hyper chord" and fire different automations. Traditionally, a Hyper key is implemented by sending to the Operating System "hyper chord" of ⌘⌥⇧⌃ by modifying the keyboard firmware or using Karabiner-elements.app. The code isn't that complex so this post will be focused on the advantages of this approach. I'm using hs.hotkey.modal to capture an F19 keystroke, and only sending the "hyper chord" of ⌘⌥⇧⌃ if absolutely required. At the moment, my hyper implementation is contained in a lua module called a, with some dependencies on Karabiner-Elements.app. I talked in the last post about my history with the concept, how I learned from Steve Losh's post on the topic and borrowed from Brett Terpstra… and I've expanded the idea a bit. Lots of people! You can find out more on our Contributors page.This all started with Hyper. If you find a bug, or have a suggestion, you can also file an issue on the issue tracker. We have a Discord server to chat about Hammerspoon. For more information, see the contribution guidelines on GitHub.īugs found on can be reported on GitHub Where can I get help? They can either be pure Lua scripts that offer useful helper functions, or you can write Objective-C extensions to expose new areas of system functionality to users. More extensions will always be a huge benefit to Hammerspoon. You can learn more about the Lua scripting language at lua.org. If you are new to Hammerspoon, read the Getting Started Guide with reference to the full API documentation. You will need to create a Lua script in ~/.hammerspoon/a using our APIs and standard Lua APIs. Out of the box, Hammerspoon does nothing. If you are using an older Mac which is not running a recent version of macOS, please consult our Release Notes for a version which is compatible with your system. How do I install it?ĭownload the latest release and then drag the application to /Applications/. You might want to do something crazy like have iTunes automatically start playing when your Mac detects you are in Paris. You might want to display an alert when your battery drops below a certain percentage. You might want to run a series of commands when your wifi interface connects to your home network. You might want to bind a keyboard shortcut to a series of window operations, or an applescript. Typically you would write a configuration file in Lua that connects events to actions. If you want to explore the options Hammerspoon offers, check out the Getting Started Guide and the full API documentation as well as the already pre-made plugins called Spoons. You can write Lua code that interacts with macOS APIs for applications, windows, mouse pointers, filesystem objects, audio devices, batteries, screens, low-level keyboard/mouse events, clipboards, location services, wifi, and more. What gives Hammerspoon its power is a set of extensions that expose specific pieces of system functionality, to the user. At its core, Hammerspoon is just a bridge between the operating system and a Lua scripting engine. This is a tool for powerful automation of macOS.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |