Anyone happen to know what I am missing?
k = hs.hotkey.modal.new('ctrl', 'd')
k:bind('', 'i', function() hs.application.launchOrFocus('iTerm') end)
Hammerspoon is listening to it but at the same time ctrl + d is ran on the focused application e.g. if it's iTerm, it executes ^D. It would be nice if it was the same as how Slate does it.
Yeah, sorry, I still need ctrl + d. It would be nice if it works only when needed. Definitely similar to how Slate does it.
Never used Slate, so that doesn’t tell me much!
Ah, my bad.
The double tap works. The application watcher seem to be a good idea as well. I’ll try to experiment with it.
The way slate does it I think is that when I press a modifier e.g. CTRL + d. It waits if another key is pressed for a few seconds (maybe ~2 seconds). If no keys are pressed then it disables the modifier which allows me to use CTRL + d normally.
You could probably do something like this (haven't tested it myself yet, but it *should* work and may be more similar to what you're used to:k = hs.hotkey.modal.new()triggerK = hs.hotkey.bind('ctrl', 'd', function() k:enter() end)function k:entered()triggerK:disable()hs.timer.doAfter(2, function() k:exit() end)endfunction k:exited()triggerK:enable()endk:bind('', 'i', function() hs.application.launchOrFocus('Terminal') end)The modal set doesn't get automatically exited when you tap `i`, so if you had other bindings as well, you'd have time to try them out if you mis-typed, but it will be exited after the 2 second delay started by the k:entered() function. As long as you hit the second ctrl-d within the 2 second window, it should go through, though.
Never used Slate, so that doesn’t tell me much!Ah, my bad.
The double tap works. The application watcher seem to be a good idea as well. I’ll try to experiment with it.
The way slate does it I think is that when I press a modifier e.g. CTRL + d. It waits if another key is pressed for a few seconds (maybe ~2 seconds). If no keys are pressed then it disables the modifier which allows me to use CTRL + d normally.
Oh, wait… do you mean that if no key follows, then the ctrl-d is sent, rather than intercepted? I’ll have to think about how that might be accomplished… it should be possible, but may involve some eventtap shenanigans, so i’m going to have to mull a bit…
Oh no, no, no. The one you sent is perfect!!! I removed the k:exited() though since I don’t really need the mistype bit. I’ll try to experiment and see if I get issues.
I’m new to both hammerspoon and lua so I’ll try to read through this. Thanks a lot!