[clue-cert] bash scripting - handy example #1

David L. Willson DLWillson at TheGeek.NU
Wed Dec 16 09:50:28 MST 2009


The following script may be useful to you, as a cron'able screen-shooter, but more, I hope it is useful to show you a bit of what is possible in a bash script.  It doesn't work with multi-head, that I'm aware of, nor does it shoot all desktops, just the active one.  Have an idea for an improvement?  Reply directly to me, or open a thread on CLUE-tech.

I cron mine like this:

   */3 * * * * /home/dlwillson/bin/takescrotscreenshot.sh >> scrot.log 2>&1

Here's takescrotscreenshot.sh:

   #!/bin/bash
   # David L. Willson, DLWillson at TheGeek.NU, 720-333-LANS
   echo -n "$(date --utc): "
   today=$(date +%Y-%m-%d.%A)
   # find /home/dlwillson/scrotscreenshots -name "200*_1440x900_scrot.png" -size 17k -delete
   if [ ! -d $HOME/scrotscreenshots/$today ]; then
      mkdir -p $HOME/scrotscreenshots/$today
   fi
   cd /home/dlwillson/scrotscreenshots/$today
   DISPLAY=:0 scrot && echo "Yay!" || echo "Bummer..."


More information about the clue-cert mailing list