sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeine
At this point, you will also notice that the applet icon looks horrible in the elementary panel. To change that, download the following icons, unzip, and merge into the elementary icon theme.
To merge, you must open pantheon-files with root access by typing the following into slingshot:
sudo apt-get update
sudo apt-get install caffeine
gksudo pantheon-files
Enter your password, and navigate to:
/usr/share/icons/elementary/
Drag the status folder into the elementary icon folder. When prompted, select "Merge."
Of course, no mention of Caffeine can be made without referencing the following xkcd comic.