#!/bin/bash if [ "$1" != "retry" ]; then maim -s > /tmp/screenshot-tmp.png fi OUTFILE=$(zenity --file-selection --save --filename=/home/josep/Pictures/screenshot.png) if [ $? -eq 0 ] && [ -f $OUTFILE ]; then zenity --question --text "Image $OUTFILE exists. Do you want to overwrite?" if [ $? -ne 0 ]; then echo "IF" sh $0 retry else echo "ELSE" mv /tmp/screenshot-tmp.png $OUTFILE fi else mv /tmp/screenshot-tmp.png $OUTFILE fi