All learnings about "linux"

…to use the original Webster dictionary under linux.

Today I read a brilliant article about English dictionaries and how to use them. It was inspiring in its colorfulness use of words and very well written, it really left me with the feeling, I need to write more. It also had an appendix about how to set up an online version of it. But it uses MacOS of course, so I had to check what works on Linux, to get a dictionary running as well. Here it is:

On Linux there have been multiple Dictionaries out there. Some were discontinued or abandoned after legal conflicts, some were left because of better alternatives. So it looks like most people settled to use GoldenDict as the standard dictionary app to use.

So you can install it via apt like so:

sudo apt-get install goldendict

Since that sparking article really left me with the desire to use the Webster dictionary from 1913, we have to download this as well. Luckily in the appendix of that article James provides an Download link to his MacOS App which contains what we need. This is an archive containing a tar.bz2-archive within the dictionary folder which we extract somewhere, our GoldenDict app can use it.

The last thing we have to do is teaching GoldenDict to use that specific dictionary. We can do that through the menu entry Edit -> Dictionary, hitting add, and choosing the directory of our previously extracted dictionary.

E voilá, if we search now within GoldenDict we get those really great definitions that really are interesting to read and explain so colorful, that a word really means.

…about 'set -o pipefail' in bash scripts.

If you use set -e to let your bash script fail when a command fails and you have some pipes within your script, you might also want to run set -o pipefail as well, since it allows bash to also discover that pipes fail.

See here for more details.

…dmenu is a great way to optimize cli scripting.

Dmenu is a simple but elegant tool from the suckless community. What it does is simply generating a dynamic menu – hence the name – using the input (text file, or piped) where every line is one menu item and let you choose from those options via keyboard cursor keys or typing the whole or partial words and in the end returning the result to stdout.

So this would simply generate a menu with two options (and a question):

$ echo "yes\nno" | dmenu -p "Are you ok?"
yes

Why is that so need? Well. I had two scripts fixing the screen setup for me, one called screenhome and the other screenwork. While that works, typing it out is annoying if you change between both setups a lot – since auto completion will suggest the last used one. Plus that are two scripts. With dmenu I could simply but them in one little script. It looks something like that:

#!/bin/bash
# This script is for fixing my screen setup.

choices="home\nwork"

chosen=$(echo -e "$choices" | dmenu -i)

case "$chosen" in
    home)
        xrandr --output HDMI-1 --above eDP-1 &&
  	    xfconf-query -c xfce4-panel -p /panels/panel-1/length -s 100 ;;
    work)
        xrandr --output HDMI-1 --above eDP-1 &&
  	    xfconf-query -c xfce4-panel -p /panels/panel-1/length -s 75
esac

I know, fixing the screen setup like this might not be the most elegant solution there could be, but that’s the one I found so far. But that is just for illustrating what you can do with it.

It can be installed by all regular means or build by hand – which is needed when you want to change the configuration like colors and stuff, since they are set on compile time (see example here).