less than 1 minute read

Zenity is for Gnome2 what gdialog was for Gnome1. You can use it display various kinds of dialog boxes from your shell scripts. Although one might think that this is superflous I find it very useful especially in combination with nautilus-action.

Let’s look at an example I found on Ubuntu Forums.


# Dialog box to choose thumb's size from pre-defined sizes
SIZE=`zenity --list --title="Choose the thumbnail's size" --radiolist --column="Check" \
      --column="Size" "" "custom" "" ">140" "" ">x90" "" ">640x480" "" ">800x600" "" ">1280x1024"`

# Dialog box to choose custom size
if [ "${SIZE}" == "custom" ]; then
    SIZE=`zenity --entry --text "Enter size parameter"`

if [ "${SIZE}" == "" ]; then    
    zenity --error --text="Size not defined by user.
                           Please choose a size to use. "
    exit 1

# $# is the argument count
let "INCREMENT=100/$#"

#Do the stuff with all the selected files ($@
(for arg in "$@"; do 
    echo "$PROGRESS";
    echo "# Resizing $arg";

    # The original image will be overwritten
    mogrify -resize "$SIZE" $arg; 
done ) | zenity  --progress --auto-close --title "$Resizing" --percentage=0

These few lines enable you to mass-convert your images to create thumbnails. mogrify is part of the ImageMagick page.