Fortune Fun

Do you need a joke to brighten your day? Maybe a word of wisdom to inspire creativity? Linux has you covered!

The fortune program (available in the Ubuntu repository) operates from the command line and offers a seemingly endless supply of wit and wisdom.

Installing fortune

sudo apt-get install fortune

Running 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

Using Zenity

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.

Have fun!

, ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: