dmenu script for quick text translation with translate-shell
- dmenu, wmenu or any other dmenu-like utility (see Configuration)
- trans from translate-shell
- xclip or wl-clipboard
- notify-send
git clone https://github.com/NikitaIvanovV/dmenu-translate
cd dmenu-translate
sudo make install
Uninstall with sudo make uninstall
If you are an Arch Linux user, you can install
dmenu-translate-git
AUR package.
yay -S dmenu-translate-git
Just run dmenu-translate
and the menu will appear:
- Enter text to translate or choose mouse text selection
- Select language to translate text into
(or select
[Define]
option to view definition of a word) - View translation in a new terminal window or copy it to clipboard
I bound Super-Ctrl-t
to call the script on my dwm build.
So, whenever I encounter a word I don't know,
I can select it with a mouse and get its definition or translation very quickly.
You might want to do something similar on your system.
The script respects TERMINAL
and PAGER
environmental variables.
You can pass addition arguments to the dmenu commands
by passing them to the script like this: dmenu-translate -arg1 -arg2
By default, only English and Russian languages appear in the menu.
You can alter this behavior by editing a configuration file located at
~/.config/dmenu-translate/config.sh
.
Example configuration file:
# Languages that appear in the menu.
TRANS_LANGS='ru en'
# Menu program.
DMENU='dmenu'
# Commands that are run to display menus.
DMENU_TEXT='' # select text to translate
DMENU_LANG='' # select language to translate to
DMENU_NEXT='' # select what to do with the translation
# Set this to any value if you want to always copy the
# translation (skips DMENU_NEXT menu).
ALWAYS_COPY=