4 ms·
I do something similar with Hammerspoon (which is an amazing app... a little bit of Lua and you can do all sorts of things to the OS!) → https://hammerspoon.or
by eddyg 3y ago
I do something similar with Hammerspoon (which is an amazing app... a little bit of Lua and you can do all sorts of things to the OS!) → https://hammerspoon.org https://hammerspoon.org
local hammerspoonHotkeys = {
F = { name='Finder' },
P = { name='1Password', alt='1Password 7' },
S = { name='Slack' },
M = { name='Music' },
W = { name='Safari' }, -- 'W' for web
...
}
for key, obj in pairs(hammerspoonHotkeys) do
trigger:bind({}, key, function() openOrHideApp(obj) end)
end
where trigger is a global hs.hotkey.modal, and openOrHideApp is a function which uses 'name' and 'alt' to switch to the app if it's not active, hides it if it's currently active, or launches it if it's not already running. It also uses hs.alert.show to quickly (just a half-second) display an overlay in the middle of screen that says "Slack" or "Hiding Slack" or "Launching Slack".
Because I'm already running Hammerspoon to do things like window management (hotkeys to move and resize windows), control my Streamdeck (without needing to run any other third-party software → https://www.hammerspoon.org/docs/hs.streamdeck.html https://www.hammerspoon.org/docs/hs.streamdeck.html) and to act as my default browser (so I can use URLDispatcher to do all kinds of "smart" things when URLs are "opened" on my Mac → https://www.hammerspoon.org/Spoons/URLDispatcher.html https://www.hammerspoon.org/Spoons/URLDispatcher.html), etc. it makes sense for me to keep adding functionality with Hammerspoon instead of adding more and more "one off" utilities.
- eviks 3y agoCan you switch between just 2 windows (current and most recent) in hammerspoon while holding (and not releasing) an arbitrary modifier key and tapping some other arbitrary key?