I want to close an editor window (it's vile a vi clone, but something that works for vim would work with vile) after some minutes of inactivity.
It's a security thing, I have a nice wrapper script that allows me to 'transparently' open and edit files encrypted using GPG but I want it to automatically close the editor window after a few minutes of inactivity.
Currently I use the following in the wrapper script just before starting the editor:-
# # # time ourselves out after five minutes by typing ZZ in the window # (sleep 300; xdotool type --window $WINDOWID ZZ >/tmp/log 2>&1) &
This works OK but has some problems:-
It doesn't work when used via SSH because xdotool is using X and there's no WINDOWID.
It will *always* send a ZZ to the window five minutes after being started, even if I've exited from the editor.
Can anyone suggest a better way of doing this? Ideally it should detect activity in the editor and only shut it down (or kill it) if there is no activity.