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.

link|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
feedback

2 Answers

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...

link|improve this answer
feedback
up vote 2 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?")
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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