Skip to content

Lightweight extension for on-the-fly manipulation to primary selections, especially optimized for Dictionary lookups.

License

Notifications You must be signed in to change notification settings

tuberry/light-dict

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Light Dict

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
license

ld

Installation

Manual

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:

E.G.O

Get it on GNOME Extensions

Features

DBus

For the DBus usage, see _ldocr.fish as a sample reference.

Methods

gdbus introspect --session --dest org.gnome.Shell --object-path /org/gnome/Shell/Extensions/LightDict

Arguments

OCR
  • params: a string (temporary parameters for OCR)
Run
  • 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

  • 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.

Dependencies

ldpref

Screencast

peek-light-dict-ocr.mp4

Command

Bash

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);

JS

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): copy LDWORD to clipboard;
  • search(LDWORD): search LDWORDin Overview;
  • key('super+a'): simulate keyboard input;

And some native JS functions like LDWORD.toUpperCase().

Notes

  • 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.

Contributions

Feel free to open an issue or PR in the repo for any question or idea.

Translations

To update the po file from sources:

bash ./cli/update-po.sh [your_lang_code] # like zh_CN, default to $LANG

Developments

To install GJS TypeScript type definitions:

npm install @girs/gnome-shell --save-dev

Acknowledgements

About

Lightweight extension for on-the-fly manipulation to primary selections, especially optimized for Dictionary lookups.

Resources

License

Stars

Watchers

Forks

Packages

No packages published