The short sleep is to allow the copy to propagate through the system and transfer the contents to the clipboard. This uses the accessibility API to retrieve the currently selected text, but if that doesn’t work, it just simulates pressing Cmd+C to invoke a copy. Local elem =hs.uielement.focusedElement() Copied from function currentSelection() This would replace the selected text, with a link! Apps like Slack and Dropbox Paper are smart enough to treat this replacement as a linking action, since it is accomplished using a regular “paste” as if the user had pressed Cmd+V themselves. With Hammerspoon, I was able to do the following: Plus JIRA has this annoying tendency to use some other URL when showing some issue, and it is easier to just type out the identifier in those cases. Of course, one could always copy paste the issue link instead of just the identifier, but the latter often looks cleaner. if you have PROJ-1234 as the ticket, JIRA will link to it), other applications are not. While JIRA is smart enough to do this within itself (i.e. We used JIRA at Dropbox, and I always preferred to have JIRA issue identifiers actually be links to the issue when possible. This uses the Hammerspoon CLI hs to call the function when the alias is run. ImportsĪlias nag_screen = 'hs -A -c "nagScreen()"' Here is how we hook this up in the Hammerspoon a. It is triggered by some shell aliases that I append to the end of the command.įor example, I can run: bazel build //something nag_screenĪnd my screen will start flashing once the build ends (regardless of success/failure), until I switch to the terminal. My solution is to use Hammerspoon to invert the entire display’s colors and keep “flashing” the display until I switch back to the terminal window. I’ve found that my brain is not great at noticing desktop notifications, since they tend to be in the top-right corner of a large display. There is a danger of getting distracted and continuing to read even when the tests are done. The usual way I respond is to continue reading the next article on my reading list. I often run build steps or unit tests that are slow enough that I can’t just twiddle my thumbs at the terminal, but fast enough that I can’t get into another cognitive task. There are some crazier applications like using voice to control scroll bars! I’m going to describe some ways I use it that are uncommon. People use it for all sorts of automations, with key remappings and quick window switchers being the most common applications. Lots of people! You can find out more on our Contributors page.Hammerspoon is a macOS automation framework that allows you to hook into all sort of OS interfaces using Lua scripts. If you find a bug, or have a suggestion, you can also file an issue on the issue tracker. You can usually get a quick answer in our IRC channel, #hammerspoon on Libera. 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. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |