Questions tagged [hammerspoon]

This tag should be used for questions related to lua automation tool for OSX

should be used for questions related to automation tool for

Sample

Pressing ctrl+G will display a Sample Alert! notification on your screen.

hs.hotkey.bind({"cmd"}, "S", function()
  hs.alert.show("Sample Alert!")
end)

References

70 questions
2
votes
1 answer

how can I run a script when I create a new workspace on my Mac?

I want to add a sticky note to my workspace when I created it automatically,but I don't know what's the event when I created a new space? Can I use applescript or Hammerspoon?
karl
  • 57
  • 8
2
votes
1 answer

Command+DELETE no longer working on Hammerspoon once the app focus switches to another

I'm now writing my own init.lua on Hammerspoon, and would like to remap some of my kews to others. Specifically, I would like to switch backslash key and delete key on my macOS. However, while the simple delete and backslash works properly, once I…
Blaszard
  • 30,954
  • 51
  • 153
  • 233
2
votes
2 answers

Why does hammerspoon return focused window nil when it should not?

I was trying to use hammerspoon to control my windows (on MAC OSX) but was having some issue. Straight from the getting started page I copied the code for moving the focused window left: hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Left", function() …
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
1
vote
0 answers

Can I edit Finder context menu items with Hammerspoon?

With Automator I can create Quick Actions in Finder. Is it possible to do the same thing with Hammerspoon?
Andreas Jansson
  • 3,137
  • 2
  • 30
  • 40
1
vote
1 answer

Move specific application to a specific screen

I have read over here how to move an application to a specific screen. In my case I have a variation of this. In this case I want to open for example Todoist on a specific screen. This code below opens Todoist but on my wrong screen. How can I solve…
sanders
  • 10,794
  • 27
  • 85
  • 127
1
vote
1 answer

Hold mouse key to scroll in hammerspoon

I currently trying to setup a lua script in hammerspoon on mac so that when I hold down the back/forward side buttons on my mouse, I can scroll up and down continuously as long as the button is held down. Indeed, the following code is what I have so…
Andrew Yuan
  • 209
  • 1
  • 7
1
vote
1 answer

How to expand text or snippet with the help of HammerSpoon?

Can we use HammerSpoon to expand text just like aText or TextExpander ? There is hs.eventtap.keyStrokes("asdf") but how to detect the keystroke and expand the text? E.g. One use case is to expand mme -> myemail@address.com. How to achieve this with…
arpit
  • 728
  • 7
  • 22
1
vote
1 answer

What's the hot key for TAB in .lua? hammerspoon?

I would like to do an ALT + TAB after the COPY: hs.eventtap.keyStroke({"cmd"}, "C") In this code SOURCE by user: @user3439894 So, normally it would be something like this, as suggested by @Oka: hs.eventtap.keyStroke({"alt"}, "tab") and…
sebseb
  • 93
  • 1
  • 1
  • 8
1
vote
1 answer

How to click on a specific button

I'm new to Hammerspoon, but interested in automating some macOS workflows with it. I know how to send keystrokes, but how do I simulate a mouse click on a specific button in a window or dialog? (I'm currently trying to close a dialog window that…
Andreas Rozek
  • 392
  • 4
  • 12
1
vote
1 answer

Hammerspoon hs.application:kill() not callable

Trying to get Hammerspoon to quit (kill) the Music app in OS X whenever it opens. (This application has been installed by Apple in such a way as to make it very difficult to alter and it launches whenever a bluetooth device is connected. Annoying…
1
vote
1 answer

Selecting a Menu Item with Hammerspoon

I try to use Hammerspoon to open a new window in Firefox with the following script: function newWindow() local app = hs.application.find("Firefox") print(hs.inspect.inspect(app)) print(app:title()) print(app:bundleID()) …
Oliver
  • 3,815
  • 8
  • 35
  • 63
1
vote
0 answers

How to bind multiple keys with hotkey.bind?

like when I type "aq", to output "Ask a public question" hs.hotkey.bind({}, "aq", function() hs.eventtap.keyStrokes("Ask a public question") end)
noxin88
  • 11
  • 1
1
vote
1 answer

How to create spoon of hammerspoon in right way?

I wrote a spoon script to control volume, but the hotkeys.bind method doesn't work, what is the problem? Here is the init.lua of the spoon -- === Volume === local obj={} obj.__index = obj -- Metadata obj.name = "Volume" obj.version =…
ivaquero
  • 69
  • 6
1
vote
0 answers

How to bind bluetooth headset control clicks with hammerspoon?

I am trying to detect eventtaps on my bluetooth headset and write some custom logic using Hammerspoon hs.eventtap module. Following is a minimal code snippet in init.lua: function mediaKeyCallback(event) print(event:getType()) end eventtap =…
1
vote
1 answer

translating working lua code (for hammerspoon) to fennel; expected userdata type

Caveat: I don't really know lua or fennel, though I do have a lot of experience in lua-like languages (python etc.) and fennel-like languages (clojure, elisp, etc.). But: I was using hammerspoon to manage external monitor configuration on my mac. I…
Paul Gowder
  • 2,409
  • 1
  • 21
  • 36