OK, here's another shot at it.
# Make sure we have a local temp directory
# (This is a good thing to have for other uses as well.)
if ! [ -d ~/tmp/ ]; then
# Show the fortune if this is a new login or session
if [ ~/tmp/cookie -ot ~/.qt/qtrc ] || [ ~/tmp/cookie -ot /var/lib/random-seed ]; then
kdialog --title Fortune --msgbox "`fortune`"
There are several changes:
1) Instead of putting the whole fortune into ~/tmp/cookie, I just "touch" it, which creates an empty file if it doesn't exist, and updates it's time stamp if it does. (This save a fairly minor amount of space, but it is
2) I display the fortune in a KDE pop-up window. (If you aren't using KDE, just revert to the simple call to "fortune.")
3) The whole "remove" section is deleted, since "touch" is called every time.
Now, all that being said, there is an easier way to do all this if you're using KDE and you just want the fortune displayed when the user starts a KDE session:
1) Create a desktop icon that calls fortune
2) Open the file manager and move the fortune.desktop (Well, I did call mine "fortune.") file from ~/Desktop to ~/.kde/Autostart (Which you may need to create if it's not there.)
Hey, this is fun. (But my wife