Created
February 19, 2021 09:19
-
-
Save maizy/aa202ca68533aab6cbf55f77a948a765 to your computer and use it in GitHub Desktop.
Hammerspoon global search hotkey for Bitwarden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- file: ~/.hammerspoon/init.lua | |
-- https://www.hammerspoon.org/ | |
-- | |
-- Bring Bitwarden to front and focus on search field | |
-- Required accessability to be enabled in Hammerspoon & System preferences | |
function launch_bitwarden_search() | |
hs.application.launchOrFocus("Bitwarden") | |
local app = hs.appfinder.appFromName("Bitwarden") | |
if (app ~= nil) then | |
local activated = app:activate(true) | |
if (activated) then | |
-- for Dock icon mode | |
app:selectMenuItem({"View", "Search vault"}) | |
-- for menubar item mode | |
hs.eventtap.keyStroke({"cmd"}, "f") | |
else | |
hs.alert.show("π Unable to activate Bitwarden app") | |
end | |
else | |
hs.alert.show("π Bitwarden app not found") | |
end | |
end | |
-- β + Option + \ | |
hs.hotkey.bind({"cmd", "alt"}, '\\', launch_bitwarden_search) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment