#!/bin/bash
# Load functions
. /usr/bin/gl-functions

get_gui_dialog

$DIALOG --title "SCREENSHOT" --yesno "If you want to take a screenshot,\n select the window you want when the cross-pointer appears." 10 90;

if [ $? = 1  -o $? = 255 ];then
  exit
fi

sleep 1

[ -f /root/gpartedss ] && rm -f /root/gpartedss
[ -f /root/gparted.jpeg ] && rm -f /root/gparted.jpeg

xwd -out /root/gpartedss
xwdtopnm < /root/gpartedss | pnmtojpeg > /root/gparted.jpeg

[ -f /root/gpartedss ] && rm -f /root/gpartedss
if [ -f /root/gparted.jpeg ]; then
  feh -q -d --title "Preview -- Your full screen shot is /root/gparted.jpeg" -g 400x300 /root/gparted.jpeg & $DIALOG --title "GParted LiveCD" --msgbox "A screen shot named gparted.jpeg is located in /root" 10 60;
else
  $DIALOG --title "GParted LiveCD" --msgbox "Failed to get screen shot. :-/" 10 60;
fi
