This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

powtrix

By: powtrix on Oct 6th, 2009  |  syntax: Bash  |  size: 1.29 KB  |  views: 75  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. # snapshoot-kde4.sh - optimized for KDE4, tested on KDE 4.2.4
  4. # powtrix, 2009.10.06
  5.  
  6. DIR="${HOME}/snapshoots"
  7. DATE="$(date +%Y%m%d@%H%M%S)"
  8. NAME="${DIR}/pow-${DATE}.png"
  9. LOG="${DIR}/snapshoots.log"
  10. MD5SUMS="${DIR}/MD5SUMS"
  11. PID=""
  12.  
  13. vai_ksnapshoot()
  14. {
  15.   # setGrabMode notes: 0=full-screen, 1=window, 2=region
  16.   kstart -iconify ksnapshot && sleep 0.2
  17.   while [ "$PID" == "" ]; do PID="$(pgrep ksnapshot)"; done
  18.   program="org.kde.ksnapshot-${PID}"
  19.   qdbus $program /KSnapshot setGrabMode "$1"
  20.   qdbus $program /KSnapshot setTime 0
  21.   qdbus $program /KSnapshot slotGrab
  22.   sleep 8
  23.   qdbus $program /KSnapshot setURL "${NAME}"
  24.   qdbus $program /KSnapshot slotSave
  25.   qdbus $program /KSnapshot exit
  26. }
  27.  
  28. if [ ! -d "${DIR}" ]; then mkdir "${DIR}"; fi
  29. if [ "$1" = "scr"  ]; then vai_ksnapshoot 0; fi
  30. if [ "$1" = "win"  ]; then vai_ksnapshoot 1; fi
  31. if [ "$1" = "area" ]; then vai_ksnapshoot 2; fi
  32. if [ "$1" = ""     ]; then echo "use as opcoes $0 [win|scr|area]." && exit 1; fi
  33. if [[ $# = 0 ]]; then
  34.   echo "No screenshot area has been specified. Screenshot not taken."
  35.   echo "${DATE}: No screenshot area has been defined. Screenshot not taken." >> "${LOG}"
  36. else
  37.   echo "${NAME}" >> "${LOG}"
  38.   cd "${DIR}" && md5sum "pow-$DATE.png" -b >> "${MD5SUMS}"
  39.   grep "$DATE" "${MD5SUMS}"
  40. fi
clone this paste RAW Paste Data