The fortune program (available in the Ubuntu repository) operates from the command line and offers a seemingly endless supply of wit and wisdom.
sudo apt-get install fortune
Open a terminal, type fortune, and a random phrase appears.
user@computer:~$ fortune Someone is speaking well of you.
Fortune is one of those programs that is fun to play with despite its simplicity. Since fortune adheres to standard I/O, fortune can be used to generate phrases and then pass them on to other programs.
The cowsay program (also available in the repository) is an excellent example of this. By itself, cowsay displays ASCII art, but piping fortune to cowsay will make random phrases appear inside the cowsay text bubble.
To begin, install cowsay.
sudo apt-get install cowsay
At the command line, pipe fortune to cowsay.
fortune | cowsay
Both fortune and cowsay can be customized, so have a look at their man pages for more details.
man fortune man cowsay
A fortune phrase may be displayed in dialog boxes using Zenity. (For more information about Zenity, consult the built-in Ubuntu help. System > Help and Support, search for zenity, and open the Zenity Manual.) From the command line, use command substitution to produce the text for a Zenity info dialog box.
zenity --info --text="$(fortune)"
Make sure to use double quotes around the $(fortune) part –text=”$(fortune)” or else only the first word will appear. Using –text=$(fortune) shows an incomplete fortune, as displayed below.
Many fun ideas are possible with this arrangement. For example, place zenity –info –text=”$(fortune)” in a startup script (System > Preferences > Startup Applications) to be greeted with a random phrase popup upon startup.