A lightweight dictionary lookup tool for Linux that displays word definitions in a beautiful popup window and automatically adds them to your Anki flashcard deck. Perfect for language learners who want a seamless look-up-to-flashcard workflow.
- Looks up a word using the
dictcommand with the WordNet dictionary - Displays the definition in a stylish AwesomeWM popup (with scroll support)
- Automatically adds the word and definition to an Anki-compatible TSV file
- Avoids duplicates — tells you if a word is already in your deck
lookup— The Zsh script that performs the lookup and Anki card managementawesomewm-config.lua— AwesomeWM keybinding configuration for the popup interface
zsh— Shell interpreterdictanddictd— Dictionary client and server (withdict-wnfor WordNet)xsel— X11 selection tool (for clipboard integration)flock— File locking utility (usually part ofutil-linux)
- AwesomeWM window manager
- Adwaita Sans font (or modify the font in the Lua config)
# Ubuntu/Debian
sudo apt install zsh dict dictd dict-wn xsel
# Arch Linux
sudo pacman -S zsh dictd xsel
# Fedora
sudo dnf install zsh dictd xsel-
Clone the files into place:
# Make the script executable and move it to your PATH chmod +x lookup cp lookup ~/.local/bin/lookup
-
Configure the Anki file path in the
lookupscript:ANKI_FILE="$HOME/Projects/Learning/Vocab/anki_import.tsv"Change this to wherever you want your Anki import file stored.
-
Add the AwesomeWM keybinding: Merge the Lua code snippet into your
rc.luaconfiguration file (typically~/.config/awesome/rc.lua).
Press Mod + d to look up the currently selected text (X11 primary selection).
# Look up a specific word
lookup serendipity
# Look up currently selected text (uses X11 primary selection)
lookup- The script grabs the word (from argument or X11 selection)
- Runs
dict -d wnto get the WordNet definition - Displays the full output immediately to stdout
- Extracts clean definition lines (removes headers, metadata)
- Checks if the word already exists in your Anki TSV file
- If new, atomically appends it using file locking (prevents corruption with concurrent lookups)
- Returns status: "Added" or "Already in Anki"
The AwesomeWM config catches this output and displays it in a scrollable popup that can be dismissed with a click or Escape key.
The flow from "I wonder what this means" to "it's in my Anki deck" becomes: select text → Mod+d → review definition → start learning.
The script writes to a TSV file compatible with Anki's import feature:
- Field 1: Word (tab-separated)
- Field 2: Definition (properly quoted for CSV/TSV safety)
- Open Anki
- File → Import
- Select your
anki_import.tsvfile - Set field separator to Tab
- Make sure "Allow HTML in fields" is checked if your definitions contain formatting
- Map fields to your note type
- Change the dictionary: Replace
wnindict -d wnwith any other dict server database - Modify the popup appearance: Edit colors, fonts, and dimensions in the Lua config
- Change the Anki file format: Adjust the
printfstatement and field extraction logic
Do whatever you want with it. Learning should be free. 📖