Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to write a little script to ask me what I'm doing at regular intervals, but I'd like it not to grab focus if I'm in the middle of writing an email or filling in a password. The two options I've come up with are (1) notify-send/pynotify which lets me pop up a notification bubble in the top right of my screen which is perfect, but can't seem to include a text entry field; and (2) zenity and similar which bring up a window with a text field, but steal focus when they do.

share|improve this question
    
Another way to fulfil your goal would be to configure your window manager not to focus the notification window initially. Only a few window manager are configurable in this way, however. –  Gilles Nov 16 '10 at 23:47

2 Answers 2

up vote 3 down vote accepted

Aha, xprintidle seems to be the answer to my woes. It tracks mouse movement as well as keyboard, but gives idle time in milliseconds so seems good enough.

http://www.dtek.chalmers.se/~henoch/text/xprintidle.html

sleep 10 
echo waiting for me not to be busy
while [ "$(xprintidle)" -lt 3000 ]; do sleep 1; done
echo interrupting
(unset WINDOWID; zenity --title "Annoyer" --entry --text "Are we there yet?")
share|improve this answer

If in X, here is a post that contains a script monitors /dev/input/event:

The important command is:

sudo hexdump -e '48/1 "%x " "\n"' /dev/input/event1 | awk '( $29 == 1) { print "PRESS: " $13 } ( $29 == 0 ) { print "RELEASE: " $13 }'

Naturally, you need to have sudo permissions, otherwise it will become what that post suggests...

share|improve this answer

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.