Lightweight extension for on-the-fly manipulation to primary selections, especially optimized for Dictionary lookups.
L, you know what? The Shinigami only eats apples. —— Light Yagami
The latest and supported version should only work on the most current stable version of GNOME Shell.
git clone https://github.com/tuberry/light-dict.git && cd light-dict
meson setup build && meson install -C build
# meson setup build -Dtarget=system && meson install -C build # system-wide, default --prefix=/usr/local
For older versions, it's recommended to install via:
For the DBus usage, see _ldocr.fish as a sample reference.
gdbus introspect --session --dest org.gnome.Shell --object-path /org/gnome/Shell/Extensions/LightDict
- params:
a string
(temporary parameters for OCR)
- type:
'^swift(:.+)?$'
|'popup'
|'display'
(fallback) |'auto'
(follow the trigger) - text:
a string
|''
(for primary selection) - info:
a string
(for the'display'
type) |''
(for the other types) - area:
[x, y, width, height]
(the source area) |[]
(default to the cursor)
- OCR here is subject to factors such as fonts, colors, and backgrounds, which says any unexpected results are expected, but usually the simpler the scenes the better the results.
peek-light-dict-ocr.mp4
Scripts run within bash -c
:
- use envar
$LDWORD
to get the captured text (by primary selection or OCR); - use envar
$LDAPPID
to get the focused app (most likely where the text from);
Scripts run within scoped JS eval()
to provide DE related functions:
LDWORD
: the captured text;LDAPPID
: the focused app;open('uri')
: open uri with default app;copy(LDWORD)
: copyLDWORD
to clipboard;search(LDWORD)
: searchLDWORD
in Overview;key('super+a')
: simulate keyboard input;
And some native JS functions like LDWORD.toUpperCase()
.
- By lightweight, I mean that it doesn't come with any dictionary sources. :)
- For English-Chinese offline dictionaries, try dict-ecdict or dict-cedict.
- To customize appearances of some widgets, try user-theme-x.
Feel free to open an issue or PR in the repo for any question or idea.
To update the po file from sources:
bash ./cli/update-po.sh [your_lang_code] # like zh_CN, default to $LANG
To install GJS TypeScript type definitions:
npm install @girs/gnome-shell --save-dev
- youdaodict: the idea of popup
- swift-selection-search: the stylesheet of iconbar
- capture2text: the idea of bubble OCR (dialog OCR here)