#!/bin/sh
#aplay -q $ICE2KSYS_SOUND_DING &
if [ "$2" = "error" ]; then
	aplay -q "$ICE2KSYS_SOUND_ERROR" & 2> /dev/null
fi
if [ "$2" = "dialog-error" ]; then
        aplay -q "$ICE2KSYS_SOUND_ERROR" & 2> /dev/null
fi
if [ "$2" = "dialog-warning" ]; then
        aplay -q "$ICE2KSYS_SOUND_ERROR" & 2> /dev/null
fi
if [ "$2" = "dialog-question" ]; then
        aplay -q "$ICE2KSYS_SOUND_DING" & 2> /dev/null
fi
if [ "$2" = "dialog-information" ]; then
        aplay -q "$ICE2KSYS_SOUND_DING" & 2> /dev/null
fi

if ! test "$2" ; then
	image="--window-icon="exec""
else
	image="--window-icon="$2" --image="$2""
fi

if [ -n "$1" ]; then
	if [ "$1" = "0" ]; then
		buttons="--button=OK:0"
	fi
	if [ "$1" = "1" ]; then
		buttons="--button=OK:0 --button=Cancel:1"
	fi
	if [ "$1" = "2" ]; then
		buttons="--button=Abort:1 --button=Retry:2 --button=Ignore:0"
	fi
	if [ "$1" = "3" ]; then
		buttons="--button=Yes:0 --button=No:1"
	fi
	if [ "$1" = "4" ]; then
		buttons="--button=Yes:0 --button=No:1 --button=Cancel:2"
	fi
	if [ "$1" = "5" ]; then
		buttons="--button=Retry:0 --button=Cancel:1"
	fi
fi

yad --window-icon="$2" $image \
--title="$3" --text="$(echo -n $4 | awk '{print "   " $0}' | awk '{print $0 "   "}')\n" \
--center --on-top --skip-taskbar --height=95 --width=200 \
$buttons \
--borders=10 \
--buttons-layout=center
