#!/bin/bash
# Convert temperature between Fahrenheit and Celsius scales
#
# Shell script for Gnome utilizing Zenity
# Project page: http://www.ferinheighttocelsius.com/F-to-C/
# SourceForge project page: http://sourceforge.net/projects/f-to-c/
#
# Released January 2010 under GPL License: http://www.gnu.org/licenses/gpl.txt
# Author contact: http://www.multi-disciplinary.com/mdi-contact.php
#

sel=`zenity --height="300" --width="300" --list --title="Temperature Conversion" --text="Fahrenheit (F) and Celsius (C)" --column="Select" --column="Conversion direction" --radiolist " " "F to C" " " "C to F"`

if [ "$sel" == "F to C" ]; then
    tF=`zenity --entry --title="Input value" --text="Enter temperature in Fahrenheit"` 
    result=$(echo "($tF - 32) * 5 / 9" | bc -s)
    zenity --info --title="Result" --text="$tF F = $result C"

elif [ "$sel" == "C to F" ]; then
    tC=`zenity --entry --title="Input value" --text="Enter temperature in Celsius"`
    result=$(echo "$tC * 9 / 5 + 32" | bc -s)
    zenity --info --title="Result" --text="$tC C = $result F"
    
fi
exit 0

