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
0
votes
1 answer

Making the keyboard momentarily unresponsive in order to clean an M1 MacBook

I have been trying to find a way to clean the keyboard and body of my M1 MacBook Air. I used to just turn off my laptop, use a clean cloth to remove dust and fingerprints, and then turn it on. But this laptop cannot be disturbed at all without…
coffee_pls
  • 163
  • 6
0
votes
1 answer

How to get a list of functions supported by an application?

I'm new to Hammerspoon, but interested in automating some macOS workflows with it. Many examples seem to directly access functions provided by a target application itself - but how does one find out which functions are provided and how they have to…
Andreas Rozek
  • 392
  • 4
  • 12
0
votes
1 answer

hammerspoon remap a key to alt modifier

I to remap the ` key so that when I hold it it behave the same way as holding the alt key. For instance holding ` and pressing tab should behave as alt+tab. I tried this, but it doesn't work. What am I doing wrong? hs.hotkey.bind({}, "`", function()…
Hisham Hijjawi
  • 1,803
  • 2
  • 17
  • 27
0
votes
1 answer

How to distinguish between iTerm2 windows to move / resize only one of them with Hammerspoon?

I have two iTerm2 windows open, and I want to place and resize one via Hammerspoon while leaving the other one as is. hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Right", function() local layout = { {"iTerm2", "/in/my/work/dir", nil,…
Robert
  • 7,394
  • 40
  • 45
  • 64
0
votes
0 answers

In Hammerspoon init, is it necessary to assign event handlers to globals?

I just started using Hammerspoon, and wrote some initialization code (at https://gist.github.com/keithrbennett/103f57dfeb0c9346ee817825659fbf5a). I was careful not to leak global variables, but a friend pointed me to a comment posted at…
Keith Bennett
  • 4,722
  • 1
  • 25
  • 35
0
votes
1 answer

How do I convert richtext pasteboard content to plaintext with hamerspoon?

I am looking for a solution to auto convert rich-text copied to clipboard (pasteboard) to plain text one in Hammerspoon (lua code). I know how to access the pasteboard in lua but no idea on how to bind this action to the copy or paste event in order…
sorin
  • 161,544
  • 178
  • 535
  • 806
0
votes
0 answers

Why won't my Hammerspoon alert fade on close despite being supplied a fadeout duration?

According to the docs, I should be able to close an alert with a fadeout: hs.alert.closeAll([seconds]) hs.alert.closeSpecific(uuid, [seconds]) But no matter what I try, the alert just seems to close immediately (so it's never even visible). local…
Andrew Cheong
  • 29,362
  • 15
  • 90
  • 145
0
votes
2 answers

hs.eventtap.keyStroke with modifier works only after double press

I want change copy command from Cmd+c to Ctrl+c. I have this code: hs.hotkey.bind({"ctrl"}, "c", function() hs.eventtap.keyStroke({"cmd"}, "c") end) But it works only after two 'c' fast presses with Ctrl button pressed. It's not a Cmd button…
0
votes
1 answer

How to end the `sleepscript` when sleep manual?

I want to wakeup the screen.30 minutes later shut up the screen, as a tomato timer. My code is below. sleepscript = [[ tell application "Terminal" do script "Control +. C" do script "echo 'git add -A' | sudo -S sudo shutdown -s +30" …
jiexishede
  • 2,473
  • 6
  • 38
  • 54
0
votes
1 answer

MRU browser tab switching with Hammerspoon (Lua+Mac issue)

I'm feeling determined to get most-recently-used tab switching working for Chrome. To do this I have installed CLUT Chrome browser extension, which currently maps alt-w to switch to the last tab, and installed Hammerspoon, which allows intercepting…
Otto
  • 1,675
  • 2
  • 19
  • 30
1 2 3 4
5