bash

Screenshot Scripts

I've been using these for as long as I can remember.

For snapshots of a specific window:

  1. #!/bin/bash
  2.  
  3. picdir='/home/tron/pictures/snapshots'
  4. i=$(ls -1 ${picdir} | grep -o '[0-9]*' | sort -n | tail -n 1)
  5. xwd | convert - ${picdir}/snapshot$(($i+1)).png
  6. convert -thumbnail 100x100 ${picdir}/snapshot$(($i+1)).png \
  7.         ${picdir}/thumbs/snapshot$(($i+1)).thumb.png

For snapshots of the whole screen (everything that X is currently drawing):

  1. #!/bin/bash
  2.  
  3. picdir='/home/tron/pictures/snapshots'
  4. i=$(ls -1 ${picdir} | grep -o '[0-9]*' | sort -n | tail -n 1)
  5. xwd -root | convert - ${picdir}/snapshot$(($i+1)).png
  6. convert -thumbnail 100x100 ${picdir}/snapshot$(($i+1)).png \
  7.         ${picdir}/thumbs/snapshot$(($i+1)).thumb.png

I have them bound to Ctrl+PrtScn and PrtScn, respectively. If you want to also automagically upload the file to a server and put its url into the clipboard (the middle click buffer), stick this at the end of the file:

  1. ftp -n -i <<END
  2. open ftp.example.org
  3. user username password
  4. cd blah/blah/blah
  5. put ${picdir}/snapshot$(($i+1)).png snapshot$(($i+1)).png
  6. close
  7. bye
  8. END
  9. xsel -c
  10. echo "http://example.org/blah/blah/blah$(($i+1)).png" | xsel -b

I have quantum postfix

Does that mean it's running and not taking up any cycles?

  1. tron@compy:~$ sudo postfix start
  2. postfix/postfix-script: fatal: the Postfix mail system is already running
  3. tron@compy:~$ sudo postfix stop
  4. postfix/postfix-script: fatal: the Postfix mail system is not running