dmenu for Chrome and Firefox – WebExtensions
Tab search, selection and beyond with a dynamic menu program.
make chrome
Open the Extensions page by navigating to chrome://extensions
, enable Developer mode then Load unpacked to select the extension directory: target/chrome
.
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
.
Open chrome://extensions/configureCommands
to configure the keyboard shortcuts.
Open about:addons
❯ Extensions and click Manage extension shortcuts in the menu.
- 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.
Tab search. Default: Control + q.
Bring tab. Default: Control + Q.
Open bookmark. Default: Alt + q.
Search history. Default: Alt + Q.
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
// Environment variables
switch (true) {
case (typeof browser !== 'undefined'):
var PLATFORM = 'firefox'
var DMENU_EXTENSION_ID = 'dmenu@alexherbo2.github.com'
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.