cat ~/bin/my_screenshot.sh
#!/bin/bash
# after some tests - the lxdefault did not work, had
# to change the keybind-calls in .config/openbox/lubuntu-rc.xml directly
#
# xwd always ask (mousecurser changes) which window to capture in alt+print
# while scrot hat option -u to capture the focused window
#
notifysend="zenity --info --text"
FOLDER="$HOME/screenshots/"
if [ ! -d "${FOLDER}" ]; then
mkdir ${FOLDER}
fi
DATE=$(date +%Y-%m-%d-%H%M%S)
FNAME="${FOLDER}screenshot-${DATE}.png"
C=0
while [ -f "${FNAME}" ] ; do
FNAME="${FOLDER}screenshot-${DATE}.${C}.png"
let C++
done
CAPTUREROOT="xwd -root | convert - ${FNAME}"
CAPTUREWINDOW="xwd | convert - ${FNAME}"
CAPTUREROOT="scrot ${FNAME}"
CAPTUREWINDOW="scrot -u ${FNAME}"
touch ${FNAME}
#$notifysend "$0 $1"
if [ "$1" != "window" ]; then
if $CAPTUREROOT; then
$notifysend "Desktop screenshot saved!\nDesktop screenshot was saved as:\n ${FNAME}"
else
$notifysend "Desktop screenshot could not be saved!\nThere was an error."
fi
else
if $CAPTUREWINDOW; then
$notifysend "Window screenshot saved!\nWindow screenshot was saved as:\n ${FNAME}"
else
$notifysend "Window screenshot could not be saved!\nThere was an error."
fi
fi