translate anything on your screen
pock is a translator for x11 desktops like dwm, i3 and bspwm. select text in any program, press a key, and the translation appears next to your mouse. english and arabic both ways, and any other language when you ask.
cargo install --git https://github.com/saeeedhany/pock
select and translate
highlight a word or a paragraph and press your key. there is nothing to copy and no window to switch to. english turns into arabic, arabic turns into english, and a single word comes with its dictionary.
- super+a translate the selection
- a full dictionary and examples
- t pick any other language
it follows your mouse
the popup sits just below the pointer and moves with it, so it never covers the line you are reading. pin it when you want it to stay, drag it out of the way, and let it follow again.
- space pin or follow again
- drag move a pinned popup
text you cannot select
labels, buttons, menus and text inside pictures. press the screen key and everything freezes, so menus and tooltips stay put. click a line or drag a box around it. pock reads it with tesseract on your own machine, then translates it. press e to change the text, when a word comes out wrong or you want a different one, and it translates again.
- super+shift+a freeze the screen
- click read one line
- drag read a box
- e edit and translate again
keyboard first
every action in the popup has a key, and none of them needs the mouse. j and k scroll long text, and the buttons are there too, for when your hand is already on it.
- ycopy
- Ycopy the original
- stranslate it back
- tanother language
- phear it
- Phear the original
- adictionary
- fstar, to anki
- eedit the text
- rretry or refresh
- spacepin
- escclose
in the terminal too
pock is also a command line translator for pipes and scripts. when one engine fails it falls back to the next, and --json hands you everything. every translation goes into a history on your machine: search it, star the ones worth keeping for anki, or export it as csv, tsv or json.
fits your desktop
pock takes its colours from xresources, the same place dwm and st read theirs, and from pywal if you use it. change your theme and run pock reload; the popup follows.
install
pock needs rust to build and an x11 session to show the popup. the command line works anywhere.
-
build and install it
cargo install --git https://github.com/saeeedhany/pock -
for text on screen, add tesseract with english and arabic
sudo pacman -S tesseract tesseract-data-eng tesseract-data-ara bind two keys, with sxhkd or in dwm
tell pock your languages, and turn on anki if you use it
the first pock popup starts the daemon. every setting is in the readme.
~/.config/sxhkd/sxhkdrc
super + a
pock popup
super + shift + a
pock ocr
or dwm's config.h
{ MODKEY, XK_a, spawn, SHCMD("pock popup") },
{ MODKEY|ShiftMask, XK_a, spawn, SHCMD("pock ocr") },
~/.config/pock/config.toml
[languages]
primary = "ar"
secondary = "en"
[keys]
popup = "super+a"
ocr = "super+shift+a"
[anki]
enabled = true