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
1
vote
1 answer

How to implement periodic task in Hammerspoon initialization?

I thought it would be great to be notified when my network connectivity dies or is revived, so I put this in my Hammerspoon init.lua: ping = nil previousStatus = nil function pingCallback(server, eventType, ...) hs.alert.show(eventType) if…
Keith Bennett
  • 4,722
  • 1
  • 25
  • 35
1
vote
1 answer

How to set korean keyboard layout by hs.keycodes.setLayout()?

I want to change keyboard layout by using Hammerspoon. To change Thai keyboard layout, this code works. > hs.keycodes.setLayout("Thai") true But to change Korean keyboard, both codes doesn't work. > hs.keycodes.setLayout("2-Set Korean") false >…
ironsand
  • 14,329
  • 17
  • 83
  • 176
1
vote
1 answer

Change mouse scroll direction with hammerspoon

Is there a way to change the mouse scroll direction with hammerspoon? I would like to change the direction with a Shortcut.
codein1
  • 43
  • 1
  • 4
1
vote
3 answers

Hammerspoon: filter application in use

I bind some key to execute script. I need to activite bind only when Visual Studio Code window is focused. I see Hammerspoon filters functions but I don't understand how use it. Application name: Code hs.hotkey.bind({"ctrl"}, "b", function() …
Lorenzo
  • 41
  • 9
1
vote
0 answers

Inserting diacritics after the letter?

To write words with diacritics, like café or αὐτοῖς, one usually must press the dead key before the letter, like this: caf[option+e]e > caf´e > café. It's a strange choice, on a paper no one would have written the diacritic first. How can I write…
eyy
  • 26
  • 3
1
vote
1 answer

Hammerspoon: drawing a line in the title bar of a window

I am trying to draw a red line in the title bar of a focused window. For this, I created code similar to the following (it is meant to be a minimal example): function foo() f = hs.window.focusedWindow():frame() line =…
T_T
  • 1,202
  • 16
  • 22
1
vote
1 answer

remap apostrophe to other keys using hammerspoon

the problem is caused by library's bug and this had been fixed. I'm using hammerspoon and I'm trying to remap Ctrl + ' to backtick(`) but I cannot. the setting file init.lua is like below: local function keyCode(key, modifiers) modifiers =…
tsugitta
  • 75
  • 2
  • 7
1
vote
1 answer

Position two Terminal windows

I'd like to start two Terminals and put them at specific positions on my screen. I know how to do this with one Terminal but what do I have to do to open a second Terminal and position it next to the first one? Here is the code for one…
wintermeyer
  • 8,178
  • 8
  • 39
  • 85
1
vote
1 answer

In Lua Hammerspoon script, how to draw on a specific desktop?

I don't see any APIs to enumarate desktops or move drawing to a specific desktop.
Vitaly Kushner
  • 9,247
  • 8
  • 33
  • 41
0
votes
0 answers

Hammerspoon Keystroke not working on new MAC

I used to have hammerspoon configured on my previous MAC but when I switched to the new MAC (M1) the keystroke is not working while other functions are. Any idea if the new MAC could be blocking Hammerspoon to paste the message? the script that I am…
0
votes
2 answers

How to find specific chrome tab across all spaces using hammerspoon

I want to use hammerspoon to find one specific chrome tab across al chrome windows across all spaces. The only way I was able to achieve this was using osascript, which I don't like much because it means to use a big multi-line string inside Lua. I…
Danielo515
  • 5,996
  • 4
  • 32
  • 66
0
votes
1 answer

Using unknown/undefined keyboard (keymap) in hammerspoon

I have attached to my mac a keyboard with additional (nonstandard) keys. See the image at the end of post. Here is my testing Hammerspoon init.lua local hyper = {"cmd", "alt", "ctrl", "shift"} hs.hotkey.bind(hyper, "E", function() …
clt60
  • 62,119
  • 17
  • 107
  • 194
0
votes
0 answers

LUA - Hammerspoon - Loop - eventtap keeps triggering

I'm trying to write a fairly simple script for Hammerspoon where I am looping through a table of app windows. The problem is for some reason when I call hs.eventtap inside the loop it keeps firing. Any help much appreciated function toggleMute() …
Fyrebase
  • 163
  • 6
0
votes
1 answer

How to properly import a lua script from a lower directory into another one, +Hammerspoon

I am trying to create an organized library for lu functions to be configured in the hammerspoon init script, however the import syntax that I have found online doesnt seem to work the same way, or perhaps i am ignorant to something.. I have seen…
0
votes
0 answers

Hammerspoon fails to run Javascript that runs fine in Script Editor

I'm trying to get today's events from Calendar.app in Hammerspoon. I have the following Javascript, that works well in the Script Editor: But, if I paste this in a call to hs.osascript.javascript(), like this: local source = [[ var Calendar =…
sharat87
  • 7,330
  • 12
  • 55
  • 80