#!/bin/bash

############################################################
############################################################
############################################################
# Project : InfoHour
# Version : 0.1
# Dependency / Dependencies : zenity , espeak
# Language : English
# License : GNU GPL - http://www.gnu.org/licenses/gpl.html
# Author : Hilger Sébastien
# Contact : hilger.sebastien@gmail.com
############################################################
############################################################
############################################################


# ___        __       _   _                  
#|_ _|_ __  / _| ___ | | | | ___  _   _ _ __ 
# | || '_ \| |_ / _ \| |_| |/ _ \| | | | '__|
# | || | | |  _| (_) |  _  | (_) | |_| | |   
#|___|_| |_|_|  \___/|_| |_|\___/ \__,_|_|   
 
  
 
# FUNCTION / FUNCTIONS #####################################

f_Speak(){
	if [ "$(date +%M)" = "00" ]; then
		espeak -p 20 -g 20 -v en-us  "$(date +%H,) hour"
		f_Replay
		sleep 60
	fi
}

f_Display(){
	if [ "$(date +%M)" = "00" ]; then
		zenity --title="Hour" --info --text="$(date +%H:%M)"
		f_Replay
		sleep 60
	fi
}

f_DisplayAndSpeak(){
	if [ "$(date +%M)" = "00" ]; then
		espeak -p 20 -g 20 "$(date +%H) hour"
		zenity --title="Hour" --info --text="$(date +%H:%M)"
		f_Replay
		sleep 60
	fi
}

f_Replay(){
	REPLAY=$(zenity --title="HoursInfo" --list --text="Choice : " --column="Choice" Continue Stop )
	if [ "$REPLAY" = "Continue" ]; then
		BOOL=true
		
	elif [ "$REPLAY" = "Stop" ]; then
		BOOL=false
	fi
}

f_If(){
	if [ "$CHOICE" = "Voice" ]
	then
		f_Speak
	fi
	
	if [ "$CHOICE" = "Dialog box" ]
	then
		f_Display	
	fi
	
	if [ "$CHOICE" = "Voice & Dialog box" ]
	then
		f_DisplayAndSpeak
		
	fi
}
	# BODY #####################################################
	BOOL=true
	CHOICE=$(zenity --title="HoursInfo" --list --text="Choice : " --column="Mode " Voice "Dialog box" "Voice & Dialog box" )
	while($BOOL); do
		f_If
		sleep 15
	done

