From: Michael Mrozek Date: Thu, 16 Feb 2012 01:23:47 +0000 (+0100) Subject: op_datetime.sh: User can either change date/time or timezone. No forced need to do... X-Git-Tag: sz_beta3~33 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=openpandora.oe.git;a=commitdiff_plain;h=e02d17d575ef0d080e6cd87b20d2b93ecfe1588f op_datetime.sh: User can either change date/time or timezone. No forced need to do both anymore. --- diff --git a/recipes/pandora-system/pandora-scripts/op_datetime.sh b/recipes/pandora-system/pandora-scripts/op_datetime.sh index 2475539..9983023 100755 --- a/recipes/pandora-system/pandora-scripts/op_datetime.sh +++ b/recipes/pandora-system/pandora-scripts/op_datetime.sh @@ -2,43 +2,51 @@ # Set the timezone and date/time -while ! area=$(zenity --list --title "Select your time zone" --text="Please select your area" --column="Select your area" --print-column=1 "Africa" "America" "Asia" "Australia" "Europe" "Pacific" --width=500 --height=260) || [ "x$area" = "x" ] ; do - zenity --title="Error" --error --text="Please select your area." --timeout=6 -done +while mainsel=$(zenity --title="Date / Time / Timezone" --width="400" --height="250" --list --column "id" --column "Please select" --hide-column=1 --text="You can set the time and date or select a different timezone.\n" "td" "Change Time and Date" "tz" "Select Timezone" --ok-label="Change Setting" --cancel-label="Exit"); do -while ! timezone=$(ls -1 /usr/share/zoneinfo/$area | zenity ---width=500 --height=200 --title="Select your closest location" --list --column "Closest Location" --text "Please select the location closest to you") || [ "x$timezone" = "x" ] ; do - zenity --title="Error" --error --text="Please select your location." --timeout=6 -done -echo $timezone -rm /etc/localtime && ln -s /usr/share/zoneinfo/$area/$timezone /etc/localtime +case $mainsel in -#Make sure we clean up any leading zeros in the day (as Zenity freaks out) -date_d=`date +%d | sed 's/^0//'` -date_m=`date +%m | sed 's/^0//'` -date_y=`date +%Y` + "tz") + while ! area=$(zenity --list --title "Select your time zone" --text="Please select your area" --column="Select your area" --print-column=1 "Africa" "America" "Asia" "Australia" "Europe" "Pacific" --width=500 --height=260) || [ "x$area" = "x" ] ; do + zenity --title="Error" --error --text="Please select your area." --timeout=6 + done -while ! date=$(zenity --calendar --text="Please select the current date" --title "Please select the current date" --day=$date_d --month=$date_m --year=$date_y --date-format="%Y%m%d" --width=500) || [ "x$date" = "x" ] ; do - zenity --title="Error" --error --text="Please select the date." --timeout 6 -done + while ! timezone=$(ls -1 /usr/share/zoneinfo/$area | zenity ---width=500 --height=200 --title="Select your closest location" --list --column "Closest Location" --text "Please select the location closest to you") || [ "x$timezone" = "x" ] ; do + zenity --title="Error" --error --text="Please select your location." --timeout=6 + done -echo $date + echo $timezone + rm /etc/localtime && ln -s /usr/share/zoneinfo/$area/$timezone /etc/localtime + ;; -time_h=`date +%H` -time_m=`date +%M` + "td") -while ! time=$(zenity --title="Enter actual time" --entry --text "Please enter the time in 24hour format (HH:MM):" --entry-text "$time_h:$time_m") || [ "x$time" = "x" ] ; do - zenity --title="Error" --error --text="Please input the time." --timeout 6 -done + #Make sure we clean up any leading zeros in the day (as Zenity freaks out) + date_d=`date +%d | sed 's/^0//'` + date_m=`date +%m | sed 's/^0//'` + date_y=`date +%Y` -while ! date -d $time ; do - time=$(zenity --title="Enter actual time" --entry --text "Please enter the time in 24hour format (HH:MM):" --entry-text "$time_h:$time_m") -done + while ! date=$(zenity --calendar --text="Please select the current date" --title "Please select the current date" --day=$date_d --month=$date_m --year=$date_y --date-format="%Y%m%d" --width=500) || [ "x$date" = "x" ] ; do + zenity --title="Error" --error --text="Please select the date." --timeout 6 + done -DISPLAY=:0 xset s off + echo $date -date +%Y%m%d -s $date -date +%H:%M -s $time + time_h=`date +%H` + time_m=`date +%M` -DISPLAY=:0 xset s on \ No newline at end of file + while ! time=$(zenity --title="Enter actual time" --entry --text "Please enter the time in 24hour format (HH:MM).\n\nThe screen might blank out after you changed the time.\nDon't panic. Simply press a button on the keyboard.\n" --entry-text "$time_h:$time_m") || [ "x$time" = "x" ] ; do + zenity --title="Error" --error --text="Please input the time." --timeout 6 + done + + while ! date -d $time ; do + time=$(zenity --title="Enter actual time" --entry --text "Please enter the time in 24hour format (HH:MM).\n\nThe screen might blank out after you changed the time.\nDon't panic. Simply press a button on the keyboard.\n" --entry-text "$time_h:$time_m") + done + date +%Y%m%d -s $date + date +%H:%M -s $time + ;; + +esac +done \ No newline at end of file