Linux Lite Forums

Full Version: Time/date script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello agan Linux Lite community. It's been a long time. I had a hard time remembering the forum login password. ;D
Found this small remastersys-timedateset script by Tony Brijeski and switched it from yad to zenity.
Sets the time and date settings and syncs to hardware clock.
I hope you find it usefull.

Code:
#!/bin/bash # Time, Date and Timezone configuration utility for Linux Lite # Fork of Date and Time Setting Tool Copyright 2009,2011 by Tony Brijeski under the GPL V2 # TODO: add timezone settings, test on a live dvd, use image-list for the main dialog, DIALOG="`which zenity` --width 400" TITLE="--window-icon=/usr/share/icons/hicolor/24x24/apps/gnome-panel-clock.png  --print-partial --title=" TEXT="--text=" ENTRY="--entry " ENTRYTEXT="--entry-text " MENU="--list --print-column=1 --column=Pick --column=Info" YESNO="--question " MSGBOX="--info " SCALE="--scale " PASSWORD="--entry --hide-text " TITLETEXT="Linux Lite Date and Time Setting Tool" if [ $EUID -ne 0 ]; then     gksu -m '   <b>Lite Time requires Administrative privileges</b>                 Please enter your password to continue.' bash $0         exit     else : fi while [ "$SETCHOICE" != "Exit" ]; do DAY="`date +%d`" MONTH="`date +%m`" YEAR="`date +%Y`" MINUTE="`date +%M`" HOUR="`date +%H`" SETCHOICE=`$DIALOG --height 300 $TITLE"$TITLETEXT" $MENU $TEXT"Set Year Date and Time Tool\n\nTime=$HOUR:$MINUTE\nDate=$MONTH-$DAY-$YEAR\n\n" Exit "Quit" SETTIME "Set Current Time" SETDATE "Set Current Date"` SETCHOICE=`echo $SETCHOICE | cut -d "|" -f 1` if [ "$SETCHOICE" = "SETTIME" ]; then HOUR="`date +%H`" HOUR=`echo $HOUR | sed -e 's/^0//g'` SETHOUR=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$HOUR --min-value=0 --max-value=23 $TEXT"Move the slider to the correct Hour"` if [ "$?" = "0" ]; then if [ "${#SETHOUR}" = "1" ]; then SETHOUR="0$SETHOUR" fi MINUTE="`date +%M`" MINUTE=`echo $MINUTE | sed -e 's/^0//g'` fi SETMINUTE=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$MINUTE --min-value=0 --max-value=59 $TEXT"Move the slider to the correct Minute"` if [ "$?" = "0" ]; then if [ "${#SETMINUTE}" = "1" ]; then SETMINUTE="0$SETMINUTE" fi date $MONTH$DAY$SETHOUR$SETMINUTE$YEAR hwclock --systohc fi fi if [ "$SETCHOICE" = "SETDATE" ]; then DAY="`date +%d`" DAY=`echo $DAY | sed -e 's/^0//g'` MONTH="`date +%m`" MONTH=`echo $MONTH | sed -e 's/^0//g'` YEAR="`date +%Y`" SETYEAR=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$YEAR --min-value=2000 --max-value=2020 $TEXT"Move the slider to the correct Year"` if [ "$?" = "0" ]; then SETMONTH=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$MONTH --min-value=1 --max-value=12 $TEXT"Move the slider to the correct Month"` if [ "$?" = "0" ]; then if [ "${#SETMONTH}" = "1" ]; then SETMONTH="0$SETMONTH" fi SETDAY=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$DAY --min-value=1 --max-value=31 $TEXT"Move the slider to the correct Day"` if [ "$?" = "0" ]; then if [ "${#SETDAY}" = "1" ]; then SETDAY="0$SETDAY" fi MINUTE="`date +%M`" HOUR="`date +%H`" date $SETMONTH$SETDAY$HOUR$MINUTE$SETYEAR hwclock --systohc fi fi fi fi done exit 0
[member=378]misko_2083[/member], welcome back!

Good to see you are coming back once again. I hope it is to stay Smile
Thanks for a welcome.
No, I'm just visiting. Not using LL or ubuntu based any more, but I still recomend it to the new win$ows converts. You did a fine work on the bash scripts and they are evolving in a good direction.
Best regards
Misko