I have a GMail account that is set to only receive an email with a certain subject.
I need some linux commands to trigger when it finds unread versions of this email.
The commands are just application calls so I could record my desktop while it runs.
xrandr --size 1360x768
timeout 2h recordmydesktop
xrandr --size 1366x768
poll imap.gmail.com protocol IMAP
The requirement to run X commands somewhat complicates matters. Cron is not really suitable -- even if your computer is only turned on when you are logged in, the general X architecture is based on privilege separation -- commands running in your current X session have access to the GUI, others do not.
Running Fetchmail and Procmail from within your X session is kind of awkward as well, but if you have a dedicated email account for this task, I don't suppose you mind accidentally losing an email message occasionally.
Thus, instead of a Cron job, I would suggest a simple background script running from your
.xsession or similar.
#!/bin/sh while true; do fetchmail -N -d0 -f $HOME/.fetchmailrc -m "/usr/bin/procmail $HOME/.procmailrc" sleep 600 done
The Procmail recipe could look something like
:0 * ^Subject: whatever | xrandr --size 1360x768 ;\ timeout 2h recordmydesktop; \ xrandr --size 1366x768