#!/bin/sh

LIGHTDM="Exit to command line"
if [ -e /etc/init.d/lightdm ]; then
  if ! service lightdm status | grep -q inactive; then
    LIGHTDM="Logout"
  fi
fi

RET=0
ACTION=$(zenity --list --radiolist \
  --hide-header \
  --title="End session" \
  --text="What would you like to do?" \
  --column "Select" --column="Action" TRUE "Shutdown" FALSE "Reboot" FALSE "$LIGHTDM" )
RET=$?
echo $SOUND
if [ "$ACTION" = "Shutdown" ]; then
  sudo shutdown -h now
elif [ "$ACTION" = "Reboot" ]; then
  sudo reboot
elif [ "$ACTION" = "$LIGHTDM" ]; then
  kill $_LXSESSION_PID
else
   echo "cancel"
fi
