You may want to build your vocabulary on some domain specific words e.g languages, definitions etc. However, you get bored (get nowhere) if you sit there and start reading the whole list. A fun way to read the words can be by using desktop popups that goes through the list one line at a time. In linux, you can use few tools to achieve that. In this tutorial, we will build a custom script that will help you build such list.
1. Notification Plugin
I am a big fan of notify-osd. If you are on ubuntu, this is the way to go. In your terminal you can just type following command and it will create a notification.
$ notify-send 'This is my notification'
The problem is, in gnome I did not get the popup. I had to go to the message bar at the bottom (by selection Super + M) and then click the icon. This is not fun, if you are not in ubuntu.
Therefore, I choose zenity for creating a notification box. This notification box will contain the message we want to display.
2. Randomize the word list
Note: For this tutorial, I will use japanese words as an example. All the files in this tutorial will be in ~/scripts/bash/japanese_random_word/ directory.
To create the list I went to http://en.wiktionary.org/wiki/Appendix:1000_Japanese_basic_words. Copied all the list of words, formatted (removed each heading, and blank lines) and came up with the file that contains words and its proper pronunciation in each line. First five lines of that file would be like this.
にんげん、人間 – human being (ningen) じんるい、人類 – humanity (jinrui) ひと、人 – person (hito) おとこ、男 – male (otoko) おとこのひと、男の人 – man (otokonohito)
Although not required, if you want to remove few characters from each line in the beginning, you can use Ctrl + v in vim to do block selection and delete any unnecessary characters or blank characters.
You may not always want to read the list in the same order. Therefore, if you want to randomize the list, you can often run this command (once you finish reading the randomized list).
$ sort -R japanese-orig.txt > japanese-rand1.txt
We will use a file called “count” that will store our index and reset itself to first line, after it reaches the last line. You can replace the text inside this file to 1 to reset the list yourself.
$ echo "1" > count
#!/bin/bash lines="$(cat $1 | wc -l)" n="$(cat ~/scripts/bash/japanese_random_word/count)" if [ "$n" -gt "$lines" ] then n=1 fi text=$(sed -n $n"p" $1) zenity --info --title="Random word Japanese" --text="$text " echo $text n=$((n+1)) echo $n > ~/scripts/bash/japanese_random_word/count
This file will read the count file from our project directory. I did not spend much time in this script, therefore feel free to change it. Anyway you have to change the directory, where you are going to create these scripts.
#/bin/bash ~/scripts/bash/japanese_random_word/read.sh ~/scripts/bash/japanese_random_word/japanese-rand1.txt
At this point, you should have 4 (at least) or 5 files.
$ ls count japanese-orig.txt japanese-rand1.txt readjapanese.sh read.sh
File “count” has only one character “1”. File japanese-orig.txt is the unrandomized list, and other files have been discussed above.
d. Test the application
Make the scripts executable (I hope you have already done for above steps).
$ chmod +x ~/scripts/bash/japanese_random_word/readjapanese.sh $ chmod +x ~/scripts/bash/japanese_random_word/read.sh
Add a keyboard shortcut to run this script. In gnome, go to Gnome Settings -> Keyboard -> Shortcuts -> Custom Shortcuts and add an entry like this.
Name: readjapanese Command: bash /home/yourusername/scripts/bash/japanese_random_word/readjapanese.sh
I hope this tutorial helped you to create your own list. If you want to edit my files, you can get it from here. Cheers !!