Random Japanese words for Ubuntu

So I spend a lot of time in front of a computer.  This makes it a little harder to find time for vocabulary practice.

I’m not so big on expensive devices that creates a list of Japanese words or kanji – I’m sure there’s an “app for that” – but this little trick I found is free, you can set all the parameters you want, and runs on Ubuntu (and probably some other Linux distro).

Open a console and type:

notify-send こんにちは

This nifty little program pops-up a notification bubble, just like the ones were are used to see for other purposes on Ubuntu. I then create a script that randomly selects a word or expression from a database then set a cron job that runs the script every minute or so.

However, you need to tweak it if you send your message from cron. From a console, notify-send just uses your default X environment variables to display on your desktop but cron doesn’t know that and it won’t display anything. So you need to add your current X display before your script call.

DISPLAY=:0.0 notify-send こんにちは

Feel free to customize your script to your liking and make sure you read the man page to notify-send for more parameters (length of display, box title, etc.).

Happy hacking.

    • Marcus Moeller
    • 04/04. 2013 1:47pm

    Where can I find the script?

    • narc
    • 04/04. 2013 6:22pm

    I guess the title was misleading but the script is the console one-liner I explained in the article. Perhaps “script” was to broad of a term for such a simple command. But that’s all there is to it, providing you have Ubuntu or any other desktop that uses D-BUS. You can customize this “script” with any other language that can shell a command to the OS. I use php-cli with cron querying a PostgreSQL database filled with Japanese words. Once every minute, cron opens a simple php program that queries a random word in the database and calls exec(“notify-send $whatever”) which displays the word. If you need help building such a program, I’ll gladly help.

  1. No trackbacks yet.

return top