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.

  • 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
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?")

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

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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