You’re not the first to have this problem. You might find the solution here:
vk5qi wrote a script to run after an observation.
David.