dmenu for Chrome and Firefox – WebExtensions
Tab search, selection and beyond with a dynamic menu program.
Dependencies
Extensions
Installation
Chrome
make chrome
Open the Extensions page by navigating to chrome://extensions
, enable Developer mode then Load unpacked to select the extension directory: target/chrome
.
Firefox
make firefox
- Open
about:config
, changexpinstall.signatures.required
tofalse
. - Open
about:addons
❯ Extensions, click Install add-on from file and select the package file:target/firefox/package.zip
.
Configuration
Chrome
Open chrome://extensions/configureCommands
to configure the keyboard shortcuts.
Firefox
Open about:addons
❯ Extensions and click Manage extension shortcuts in the menu.
Usage
- Press Control + q to tab search.
- Press Control + Q to bring a tab.
- Press Alt + q to open a bookmark.
- Press Alt + Q to search history.
Commands
tab-search
Tab search. Default: Control + q.
bring-tab
Bring tab. Default: Control + Q.
open-bookmark
Open bookmark. Default: Alt + q.
search-history
Search history. Default: Alt + Q.
Options
dmenu
Pipe tabs through the given external filter program. Default:
{
"command": "dmenu",
"arguments": []
}
Example – Run with fzf and Alacritty:
~/.local/bin/dmenu
#!/bin/sh
# A drop-in dmenu replacement using fzf with Alacritty.
# – fzf (https://github.com/junegunn/fzf)
# – Alacritty (https://github.com/alacritty/alacritty)
# Create IO files
state=$(mktemp -d)
input=$state/input
output=$state/output
trap 'rm -Rf "$state"' EXIT
# Get input
cat > "$input"
# Run fzf with Alacritty
alacritty --class 'popup' --command sh -c 'fzf < "$1" > "$2"' -- "$input" "$output"
# Write output
cat "$output"
# Exit code
if test ! -s "$output"; then
exit 1
fi
Cross-extension messaging
// Environment variables
switch (true) {
case (typeof browser !== 'undefined'):
var PLATFORM = 'firefox'
var DMENU_EXTENSION_ID = '[email protected]'
break
case (typeof chrome !== 'undefined'):
var PLATFORM = 'chrome'
var DMENU_EXTENSION_ID = 'gonendiemfggilnopogmkafgadobkoeh'
break
}
// Initialization
const dmenu = {}
dmenu.port = chrome.runtime.connect(DMENU_EXTENSION_ID)
dmenu.send = (command, ...arguments) => {
dmenu.port.postMessage({ command, arguments })
}
// Usage
dmenu.send('tab-search')
You can find some examples in Krabby.
See the source for a complete reference.