Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
2  
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
add comment

1 Answer

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 force-screensaver.sh

#!/bin/bash

secondstowait=$1

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

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

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

ends=0
endm=0
endh=0

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

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

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

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

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

while (true)
do

    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
        echo Exiting...
        echo
        gnome-screensaver-command -d
        exit
    fi
done

You can call it passing it the number of seconds you want to torture yourself (e.g. force-screensaver.sh 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
1  
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
add comment

Your Answer

 
discard

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.