#!/bin/bash

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

zenity --question  --text="I Want My Sound Events" --ok-label="On" --cancel-label="Off"
if [ $? = 0 ] ; then
command=$(gsettings set org.gnome.desktop.sound event-sounds 'true')
else
command=$(gsettings set org.gnome.desktop.sound event-sounds 'false')
fi

#if [ ! -f /usr/bin/metacity ]; then
#  zenity --warning --text="<b>You do not appear to have Metacity installed.</b>\n\nThe Compiz GTK window decorator uses Metacity libraries to operate. The Metacity #theme is what this tool adjusts.\n\nInstall the metacity package if you would like to use the Compiz GTK window decorator."
#fi

main_window() {
  selection=$(
    zenity --height 350 --width 120  --list --ok-label="Apply" --cancel-label="Close" --title="Sound Theme Name" \
    --column="Current theme: $( if [ $(gsettings get org.gnome.desktop.sound theme-name) == "''" ]; then
        echo Default
      else
        gsettings get org.gnome.desktop.sound theme-name
      fi)" \
    "pearl-sounds" \
    $(
      for d in /usr/share/sounds/*/; do
        echo $d | sed 's:/usr/share/sounds/::' | sed 's:/::'
      done
    )
  )
}

while [ $? = 0 ]; do
if [ "$selection" == "pearl-sounds" ]; then
  gsettings set org.gnome.desktop.sound theme-name "''"
elif [ "$selection" != "''" ]; then
  gsettings set org.gnome.desktop.sound theme-name "$selection"
fi
main_window
done



IFS=$SAVEIFS
