Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As a person working in computer science working offline to avoid facebook and thelike is not always (meaning hardly ever) possible for me since I mostly have to be online to work.

I have tried leechblock and similar things but the problem becomes that at some point I start making systems for myself to hack, which is kind of pointless if oyu have root.

I would very much like to try out the method described here. (Short version: reboot your PC every time finish a task or get bored with it)

Unlike for the author of this blog my work is mainly done not in screen sessions but in IDEs ans other not-so-fast-to-start-up stuff, meaning a full reboot including loading all my programs will take its time. So, the question is:

How can I block all user input and preferrably blank the screen for a given amount of time?

The idea would then be to have a keyboard shortcut to activate the script/program (which would probably also have to have root i guess?)

share|improve this question
This is completely off topic, but read this essay which has won the igNobel prize last year. Works for me. – January Oct 2 '12 at 8:35
up vote 2 down vote accepted

So you want to treat yourself like a 16-years old boy, don't you? Ok, this should be a good starting point...

#> cat



if [ "x$1" == "x" ] ; then
    echo "Please insert the number of seconds you want to wait"

hourstowait=$(($secondstowait / 3600))
minstowait=$((($secondstowait / 60) - ($hourstowait * 60)))
secstowait=$(($secondstowait - $minstowait * 60 - $hourstowait * 3600))

starth=`date +"%H"`
startm=`date +"%M"`
starts=`date +"%S"`


ends=$(($ends + $starts + $secstowait))
if [ $ends -gt 59 ] ; then
    ends=$(($ends - 60))
    endm=$(($endm + 1))

endm=$(($endm + $startm + $minstowait))
if [ $endm -gt 59 ] ; then
    endm=$(($endm - 60))
    endh=$(($endh + 1))

endh=$(($endh + $starth + $hourstowait))

echo "Will wait for $hourstowait hours, $minstowait minutes and $secstowait seconds"

printf "Starting at %02d:%02d:%02d - stopping at %02d:%02d:%02d\n" "$starth" "$startm" "$starts" "$endh" "$endm" "$ends"

while (true)

    currh=`date +"%H"`
    currm=`date +"%M"`
    currs=`date +"%S"`

    #echo "Running..."
    gnome-screensaver-command -a

    #sleep 5

    if [ $currh -ge $endh ] && [ $currm -ge $endm ] && [ $currs -ge $ends ] ; then
        echo Exiting...
        gnome-screensaver-command -d

You can call it passing it the number of seconds you want to torture yourself (e.g. 60 it's the maximum I've been able to stand). Then you just have to bind it to a keyboard shortcut and you're done.

Have a nice pain :P

share|improve this answer
it doesn't look nice but then again, it's not supposed to be. As you said, it's supposed to be a pain ;) – black_puppydog Oct 2 '12 at 9:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.