Skip to content

marvinkreis/rofi-json-dict

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Reads all JSON files in a directory (default: XDG_DATA_HOME/rofi-json-dicts) as dictionaries and lets the user query translations.

Screenshot

Dictionaries

Dictionaries have the following structure:

{
    "key1": "value1",
    "key2": "value2",
    "key3": "value3"
}

They must be saved in UTF-8 with the .json file extension.

The convert-dict python script can be used to convert FreeDict dictionaries into the JSON format.
Usage: convert-dict input.tei output.json.

Matching modes

This plugin supports three matching modes:

# Mode Description
0 exact match if the key matches the search string exactly
1 substring match if the key contains the search string
2 Levenshtein distance match if the Levenshtein distance is below a threshold (default: 2)

Key-Bindings

Key Action
kb-mode-next
(default: Shift+Right)
Switch to the next matching mode.
Switch to the next rofi-mode if the last matching mode is already selected.
kb-mode-previous
(default: Shift+Left)
Switch to the previous matching mode.
Switch to the previous rofi-mode if the first matching mode is already selected.
kb-accept-custom
(default: Control+Return)
Switch to the next matching mode (only if the input is empty).

Command line options / Configuration

Option Description
-json-dict-path <path> Sets the dictionary directory (default: XDG_DATA_HOME/rofi-json-dicts).
-json-dict-mode <0|1|2> Sets the matching mode (default: 0).

The source file contains more configuration via #define.

Example configuration

$ ls ${HOME}/.local/share/rofi-json-dicts
deu-eng.json
eng-deu.json
eng-fra.json

rofi -modi json-dict -show json-dict -json-dict-path "${HOME}/.local/share/rofi-json-dicts" -json-dict-mode 0

Compilation

Dependencies

Dependency Version
rofi 1.6
json-c 0.13

Installation

Use the following steps to compile the plugin with CMake:

cmake .
make
make install # optional: install the plugin