How to setup a popup Perseus' dictionary for Linux OS

By bathtime, in 'Latin Language Resources', Nov 23, 2017.

  1. bathtime Member

    I've tried GoldenDict and it just is not working as I would like it to, so, after having pulled out much of my hair, I found a working solution:


    This setup will allow you to:
    • Instantly look up a chosen word in your preferred browser on Perseus' web dictionary.
    • Select and look up that word by merely highlighting it in any application (no copy or other commands/selections needed)
    • Turn on and off this program with a shortcut (I will show how it is done in KDE)
    • Have the word be looked up only if it is one word and has no other elements before or after it so that only acceptable characters will be passed through to the dictionary.

    I admit that this is a trifle involved, but after this is done, the convience is quite amazing. :)

    COPYQ SETUP

    First you will need to install 'copyq.' This will be the application that will look for the words you will highlight and execute a command to bring up a dictionary.

    It can be found here:
    https://www.linuxbabe.com/apps/install-copyq-best-linux-clipboard-manager

    To start the copyq server, type:
    Code:
    $ copyq
    For some reason copyq will not show a window unless the following command is ran:
    Code:
    $ copyq show
    Once running, goto:
    (Menu) File -> Commands/Global Shortcuts.

    Click '+ Add' and select 'New Command.'
    (You may Rename this to 'Perseus' in the 'Name:' input box.)

    Under 'Type of Action,' select:
    [x] Automatic (which allows the word to be selected by merely highlighting it)

    Under the input field 'Match Items -> Content,' type:
    Code:
    ^(\w)+$(?!\W)
    This will bring the dictionary up only if the selected text begins, remains, and ends with proper letters; it will not accept commas, dots, and other symbols, which the dictionary does not allow.

    Under 'Match Items -> Format' input box, select 'text/plain.'

    Under the 'Command' input box at the bottom, type (I use qupzilla, but you can substitute your brower name):
    Code:
    qupzilla http://www.perseus.tufts.edu/hopper/morph?l=%1&la=la#lexicon
    The '%1' being the word to be inserted into the HTML link.


    Press 'Apply' and 'Okay.'

    Select a word of text with the mouse. If it is working it should automatically popup a browser window as soon at the text is selected and the mouse button released.



    TURNING IT ON AND OFF WITH A SHORTCUT

    You will not want this program on all the time, else you might be having a dictionary popup when you don't want it to. A shortcut may be created to help with this:

    I will show only how to do this in KDE, though I'm sure such a thing can be done with different window managers.

    Right Click on the KDE menu icon and click 'Edit Application.' Make a duplicate of the 'CopyQ' application by selecting, copying, and pasting it. You could rename the first 'CopyQ - Start.' Click on the 'copyq - start' entry, and then the 'Advanced' tab and click the input box that says 'Current shortcut key.' At this point, just click the key combination which you would like to use to start this application up. I pressed Ctrl and A (at the same time!), and I see a 'Ctrl+A' in the box.

    Move down to the second 'CopyQ' menu item (the one that you made a copy of) and repeat the step above to activate it, with the difference that you will use Ctrl + Z as your shortcut keys. Renamed the application title to 'CopyQ - Stop.'

    Goto the 'General' tab and to the 'Command:' input box and enter:
    Code:
    copyq exit

    I should warn you that though this will allow you to look up a word by selecting it, it will not look up a selected word within the browser that the result is in; you must use two different browsers if you wish to use the net and this functionality. You must also close the browser after each word lookup.


    Enjoy.
    Quasus likes this.
  2. Quasus Civis Illustris

    • Civis Illustris
    Location:
    Coimbra, Portugal
    Great.

    As an alternative, one could use a simpler tool like xclip and bind e. g
    Code:
    surf "http://www.perseus.tufts.edu/hopper/morph?l=$(xclip -o)&la=la#lexicon"
    to a shortcut.

    A more robust solution could involve url-escaping, but this one is good enough if one is careful not to select a few words at a time.
    bathtime likes this.
  3. bathtime Member

    I like your way much better. I don't mind having to select the words properly so long as I can just highlight the word (and not have to take the extra step of copying it).

    I just threw this command in a short-cut:
    Code:
    surf -D -p -i -n -z 1.5 "http://www.perseus.tufts.edu/hopper/morph?l=$(xclip -o)&la=la#lexicon"
    Where the -z arguement zooms the browser a little for aged people like me. ;) -D enables disk cache and -p disables plugins. -i disables images and -n disables web inspector.
    Quasus likes this.

Share This Page

 

Our Latin forum is a community for discussion of all topics relating to Latin language, ancient and medieval world.

Latin Boards on this Forum:

English to Latin, Latin to English translation, general Latin language, Latin grammar, Latine loquere, ancient and medieval world links.