aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2013-03-27 13:19:49 +0100
committerLaurent Ghigonis <laurent@p1sec.com>2013-03-27 13:19:49 +0100
commit23216a1176fb58d6d9e6b6d5dd5334e42a31381a (patch)
tree5ae7efc58446958a20719090c7b4c38f4049f45f
parentadd qvm-copy-to-vm.sh, to copy files from Qubes Dom0 to AppVM (diff)
downloadlaurent-tools-23216a1176fb58d6d9e6b6d5dd5334e42a31381a.tar.xz
laurent-tools-23216a1176fb58d6d9e6b6d5dd5334e42a31381a.zip
add qvm-screenshot.sh, to take screenshot in Qubes Dom0 and copy to AppVM
-rw-r--r--tools/qvm-screenshot.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/tools/qvm-screenshot.sh b/tools/qvm-screenshot.sh
new file mode 100644
index 0000000..a081d45
--- /dev/null
+++ b/tools/qvm-screenshot.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+# Take screenshot in Qubes Dom0 and copy to AppVM
+# Dependencies: scrot (sudo qubes-dom0-update scrot)
+# 2013, Laurent Ghigonis <laurent@p1sec.com>
+
+DOM0_SHOTS_DIR=$HOME/shots
+APPVM_SHOTS_DIR=/home/user/shots
+QUBES_DOM0_APPVMS=/var/lib/qubes/appvms/
+
+usage() {
+ echo "$program [-hlms]"
+ echo -e "\t-m : take multiple shots"
+ echo -e "\t-n : after screenshot, run nautilus in AppVM"
+ echo -e "\t-s : select window"
+}
+
+program="`basename $0`"
+mode_multi=0
+mode_nautilus=0
+mode_select=0
+opts="$(getopt -o hmns -n "$program" -- "$@")"
+err=$?
+eval set -- "$opts"
+while true; do case $1 in
+ -h) usage; exit 1 ;;
+ -m) mode_multi=1; shift ;;
+ -n) mode_nautilus=1; shift ;;
+ -s) mode_select=1; shift ;;
+ --) shift; break ;;
+esac done
+[[ $err -ne 0 ]] && usage && exit 1
+
+shotslist=""
+mkdir -p DOM0_SHOTS_DIR ||exit 1
+while true; do
+ d=`date +"%Y%m%d-%H%M"`
+ tmpname=$d.png
+ if [ $mode_select -eq 1 ]; then
+ echo "[-] making shot, click on a window"
+ scrot $@ -s $DOM0_SHOTS_DIR/$tmpname ||break
+ else
+ echo "[-] making shot of root window"
+ scrot $@ $DOM0_SHOTS_DIR/$tmpname ||break
+ fi
+
+ title=`kdialog --inputbox "Enter screenshot title" --title "shot.sh"`
+ shotname=${d}_${title}.png
+ [[ X"$title" = X"" ]] && break
+
+ echo "[-] saving $DOM0_SHOTS_DIR/$shotname"
+ mv $DOM0_SHOTS_DIR/$tmpname $DOM0_SHOTS_DIR/$shotname
+
+ shotslist="${shotslist}${shotname}:"
+
+ [[ $mode_multi -eq 1 ]] && kdialog --yesno "Other shot ?" || break
+done
+
+choice=`ls $QUBES_DOM0_APPVMS |sed 's/\([^ ]*\)/\1 \1/g'`
+appvm=`kdialog --menu "Select destination AppVM" $choice --title "shot.sh"`
+
+if [ X"$appvm" != X"" ]; then
+ if [ $mode_nautilus -eq 1 ]; then
+ echo "[-] running nautilus in AppVM"
+ qvm-run $appvm "nautilus $APPVM_SHOTS_DIR"
+ fi
+
+ echo "[-] copy to AppVM $appvm"
+ qvm-run $appvm "mkdir -p $APPVM_SHOTS_DIR"
+ IFS=":"; for shot in $shotslist; do
+ echo "[-] copying $APPVM_SHOTS_DIR/$shot"
+ cat $DOM0_SHOTS_DIR/$shot \
+ |qvm-run --pass-io $appvm "cat > $APPVM_SHOTS_DIR/$shot"
+ done
+ echo "[*] done $appvm"
+else
+ echo "no AppVM name provided"
+ echo "[*] done"
+fi
+