
sd: the dictionaries collections manager for StarDict


The sd script allows you to use interchangeably any number of the collections of the dictionaries with StarDict. Theoretically the groups or the trees of the dictionaries should serve these purposes but I prefer simpler solutions so I did not try too hard to define these groups or trees. I wrote instead the sd script. 

I use StarDict with 63 different dictionaries, lexicons, and encyclopedias separated into five main groups: German (de), English (en), French (fr), Polish (pl), and Russian (ru). It is not possible to run them all at the same time because it is too much for this program. 

So I prepared five subdirectories in the /usr/share/stardict/ directory:

    dic.de
    dic.en
    dic.fr
    dic.pl
    dic.ru

Each of them contains the dictionaries for the respective languages. 


1. Changing the privileges:

In order to be able to switch your collections as a regular user change the group and the mode of the /usr/share/stardict/ directory using the commands:

    chgrp users /usr/share/stardict
    chmod 775 /usr/share/stardict

These commands are stored at the beginning of the sd script. So uncomment them, run the script as root, and comment these commands back. From now on you may use this script as a regular user. 


2. Preparing the template configuration file:

Make sure that there is no stardict.cfg file in the ~/.stardict directory and there is no dic subdirectory in the /usr/share/stardict/ directory. Then run StarDict for the first time, set all options according to your preferences, and exit StarDict. 

Next prepare the template configuration file using the commands:

    cd ~/.stardict
    mv stardict.cfg stardict.cfg.template


3. Preparing the collections:

Go to the /usr/share/stardict/ directory and make the subdirectories for your collections using the following naming convention:

    dic.NAME1
    dic.NAME2
    dic.NAME3

for example:

    dic.de
    dic.en
    dic.fr

Then copy the appropriate dictionaries into the right subdirectories. Do not use the dic subdirectory at all.


4. Preparing the configuration files:

Use the commands such as:

    sd NAME

to copy the template configuration file to the current configuration file. 

Then run StarDict, sort the dictionaries, and exit StarDict.

Finally move the current configuration file into the right file:

    cd ~/.stardict
    mv stardict.cfg stardict.cfg.NAME

Repeat these steps for all your collections. As a result at the end you should have in the ~/.stardict directory the files such as:

    stardict.cfg.de
    stardict.cfg.en
    stardict.cfg.fr


5. Testing the configuration:

$ sd
dic -> dic.en
dic.de
dic.en
dic.fr

In the above case the dic symbolic link points the dic.en collection.


6. Switching the collection:

$ sd fr
dic -> dic.fr
Dictionnaire Littre, 1877 (Fr-Fr)
Dictionnaire de l'Academie Francaise, 8eme edition, 1935 (Fr-Fr)

In the above case the dic symbolic link was changed to point the dic.fr collection including two dictionaries.


7. Checking the dictionaries:

$ sd de ?
English - German 2.4.2 (En-Ge)
FreeDict English - German 2.4.2 (Ge-En)
FreeDict German - English 2.4.2 (Ge-En)
German - English 2.4.2 (Ge-En)
Neolingus Niemiecko - Polski 2.4.2 (Ge-Pl)
Neolingus Polsko - Niemiecki 2.4.2 (Pl-Ge)

There are six German dictionaries in the dic.de collection.

