Fixing Firefox Email Shortcut with Hammerspoon

Fixing Firefox Email Shortcut with Hammerspoon

Hammerspoon is a small macOS automation tool. You can write Lua code blocks that can handle keyboard events and more.

Firefox used to have a File > Email Link menu that you could assign a shortcut in macOS keyboard shortcuts.

One fine day Firefox or macOS moved this under File > Share > Mail. That breaks my shortcut πŸ˜‘.

Firefox share menu

I would have updated my shortcut but macOS Big Sur can't assign shortcuts to nested menus πŸ₯². I really wanted that shortcut back because I use it a lot to email web pages. So I turned to Hammerspoon and hacked together this script.

-- Email the current page 
hs.hotkey.bind({"cmd", "shift"}, "I", function()
  firefox = hs.appfinder.appFromName("Firefox")
  firefox:selectMenuItem({"File", "Share", "Mail"})

This adds a global shortcut Command + Shift + I to trigger that menu πŸ₯³.

Since you are already here let me share another one I use regularly.

-- paste as keystrokes
hs.hotkey.bind({"cmd", "shift"}, "V", function() 

With that Command + Shift + V pastes plain text by typing keystrokes. This also bypasses some smart websites that don't let you paste your password πŸ˜‰.

Check out Hammerspoon and Lua. Maybe you can fix or automate something that annoys you.