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.
3 Answers
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...
What about w
and tail -f dev/pts/13
where 13
is the pts of the user you want to spy from w
?