Howto Get Enough Sleep Despite StumbleUpon with Ubuntu

What?

I am a long-term StumbleUpon user, which means that I don’t get much sleep. Now, after almost 4 years of stumbling, I have decided to get my life back. Well, at least some sleep!

What does this do?

Every night when I have to work on the next day (Sunday night to Thursday night ), at 23:25 my computer shows me this little warning message:

go to bed warning

After the 5 minutes have passed, the computer shuts itself automatically down.

I use this little trick with Ubuntu, but it should work anywhere where Gnome is installed.

How?

Thanks to the power of Linux, this is not difficult to do for yourself, and configure it however you want it to behave:

  1. Open /etc/crontab with your favourite text editor (no need for crontab -e since this is the system wide crontab), e.g.
  2. Add the following lines (replace manker with your username!)

  3. The first part of both lines 25 23 * * 0-4 means that the commands are executed at 23:25, but only Sunday (day 0) to Thursday (day 4). Read man 5 crontab for a detailed description of that format.
  4. The first command uses zenity to show a warning message. You have to execute this as the same user that you use for working, or you will not see the message, so change manker to your username (root does not work either).
  5. The second command shutdown -h +5 means that the computer will halt in 5 minutes. This has to be run as root, and it also shows nice warning messages in all your open terminals so you can’t really miss it.
  6. Save the file, and stumble until it is 23:25.

Sweet dreams!

75 Comments on "Howto Get Enough Sleep Despite StumbleUpon with Ubuntu"

Notify of
avatar
DBautell
Guest

Maybe the “I ain’t got no warning” people don’t have zenity;
for Ubuntu and other Debians, you may need to:
sudo apt-get zenity

From a shell or the run dialog, try;
zenity –display :0 –warning –text=”Is this thing on?”
or (definitely from a shell);
which zenity
to test whether you have it.

But who shuts their machine off? BOINC has got work to do.

Scotto
Guest

FYI for anyone on Ubuntu not getting warnings. Try the command “xhost +” I couldn’t get warnings until I found the solution on this website. This disables access control (might be a bad thing).

http://preview.tinyurl.com/6q4n6l

I now have warnings. Not sure if this opens a security hole on my system though. Time to go RTFM.

sonicBoom
Guest

Great idea! Ingenious and simple. Updated my crontab directly. Gonna get my sleep back! Thanks a lot!

Rogier Maas
Guest

Oh THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU!!!!!!!!

I’ve had the BEST sleep last night in bloody AGES!!

THANK YOU *SO MUCH*!!!!!

lol

trackback

[…] zainspirowany tym wpisem (sk?din?d znalezionym dzi?ki StumbleUpon…): http://martin.ankerl.com/2008/01/24/howto-get-enough-sleep-despite-stumbleupon-with-ubuntu/ Brak komentarzy, Zostaw komentarz lub […]

pepeRu
Guest

omg! it’s a dign.. that i should go to sleep, I stumbled upon this.. using ubuntu at 12:20 am >_< good night

Kunal Gautam
Guest

Mate Really nice and usefull Tip 🙂 thanks for sharing

John Deszell
Guest

Oh how I get sucked into Stumbleupon sometimes. In fact I found this page on Stumbleupon.

Giving it a thumbs-up!

ToastyMallows
Guest

Thanks a lot man, this helps my Stumble addiction.

trackback

[…] post about me struggling with getting enough sleep despite StumbleUpon was by far the most viewed article on the blog, it has received more than 4 times as much visits as […]

Anonymous
Guest

how about the atd.
its not always sure you want to shut down your whole pc in 5 minutes every day at a specific time.

type something like that:

sudo at now + 1 hour
xmessage go to bed already
shutdown -h +5

sykot1c
Guest

Dude Thats Cool!!

trackback

[…] ???? ????? cron ?? ???? ??????? Categories: ?????? ??????????????, ????, ??????, ?????, ?????? ????????? (0) ????????? (0) ?????????? ?? ???????: ?????? […]

eric
Guest

that is so awesome!

the ironic thing is i stumbled upon this 😛

corkit08
Guest

haha STUMBLED!! why must this be so addictive?

falky
Guest

Didn’t know zenity yet, very n1, thx 🙂

trackback

[…] ??Link? You can follow any responses to this entry through the RSS 2.0 feed. You can leave a […]

polaris
Guest

I think “–display :0” must be “–display=:0”
Isn’t it?

Martin Ankerl
Guest

Hi polaris, I have just tried it, both --display :0 and --display=:0 work.

Martin Ankerl
Guest

The --display parameter needs to be on the same display as X is currently running, which is stored in the $DISPLAY environment variable. Unfortunately this variable is not set when running from crontab, so I have just hardcoded :0. To find out where your X is running, type echo $DISPLAY and then add this output to the crontab.

Willie Matthews
Guest

I love this, I am also a Ubuntu users. It is 10.30AM right now here in Las Vegas, Nevada and I have been stumbling from 5.30AM. I Stumbled to this site. I guess that is a hint that I need to put some kind of timer on my stumbling.

Amby
Guest

You could also try Workrave. It’s a pretty cool and healthy little app.

Ben in Seattle
Guest

Many people here say they found this article through StumbleUpon. I’m the opposite. I’m now installing StumbleUpon because I read this article.

Rich
Guest

As a Systems and Security admin, I justify stumbling at work. All my categories are work related, (eg: hacking, network security, web dev tools, etc…). You’d be surprised how much I’ve found that I now use daily because I found it while stumbling at work. No need to shutdown 🙂

michael busto
Guest

But I have StumbleUpon on my phone! I go to bed and stubble from there! Good idea though.

wpDiscuz