You are not logged in.

#1 2013-09-26 13:31:13

aaditya
Member
Registered: 2013-09-01
Posts: 174

A script to manage system time (+GUI available by Frodouser-senior)

Hi!

I have created a very simple script in bash in order to manage the time(system time and date).

Its called timeset.
-------------------------------------------------------------------------
Its in the AUR now.
https://aur.archlinux.org/packages/timeset/
-------------------------------------------------------------------------
GUI available.
https://aur.archlinux.org/packages/timeset-gui/
-------------------------------------------------------------------------

it can be downloaded from here https://www.dropbox.com/s/daz26fiil0134gw/timeset
After downloading you will need to make it executable.

sudo chmod +x ~/timeset

After then copy it to the /usr/bin directory for easy access

sudo cp ~/timeset /usr/bin

(Assuming that it has been downloaded to the home folder.)
Otherwise it should be sudo chmod +x <path-to-timeset> and sudo cp <path-to-timeset> /usr/bin.

To run it

sudo timeset

To run the GUI

gksudo timeset-gui

Last edited by aaditya (2013-11-22 18:52:46)

Offline

#2 2013-09-26 14:09:47

aaditya
Member
Registered: 2013-09-01
Posts: 174

Re: A script to manage system time (+GUI available by Frodouser-senior)

Here is a screenshot  smile
th_timeset-11.png

Here is the code.
Its my first bash script smile

#!/bin/bash
#
##timeset- A script-utility to configure the system date and time
##Author- Aaditya Bagga
#

ROOT_UID=0     # Only users with $UID 0 have root privileges.
E_NOTROOT=87   # Non-root exit error.

# Run as root, of course.
if [ "$UID" -ne "$ROOT_UID" ]
then
  echo "Must be root to run this script."
  exit $E_NOTROOT
fi  

#
#Menu
#
while :
 do
    clear
    echo "------------------------------------------------------------------------------"
    echo " TimeSet(tings) - Configure the System Date and Time "
    echo "------------------------------------------------------------------------------"
    echo ""
    echo "[1]  Show Current Date and Time Configuration"
    echo "[2]  Show Known Timezones (press q to return to menu)"
    echo "[3]  Set System Timezone"
    echo "[4]  Synchronize Time from the Network (NTP)"
    echo "[5]  Control whether NTP is used or not"	
    echo "[6]  Enable NTP at Startup"
    echo "[7]  Disable NTP at Startup"
    echo "[8]  Control whether Hardware Clock is in Local Time or not"
    echo "[9]  Read the time from the Hardware Clock"
    echo "[10] Synchronize Hardware Clock to System Time"
    echo "[11] Synchronize System Time from Hardware Clock"
    echo "[12] Set System Time manually"
    echo ""
    echo "[q]  Exit/Quit"
    echo "==========================================================="
    echo -n "Enter your choice [1-12,q]: "
    read choice
    case $choice in
      1) echo "Current Date and Time"; timedatectl status; echo "Press a key. . ."; read;;
      2) echo "TimeZones";timedatectl list-timezones ;;
      3) echo -n "Enter the TimeZone (it should be like Continent/City): " ; read tz ; timedatectl set-timezone $tz ;echo "Press a key. . ."; read ;;
      4) echo -e "Synchronizing time from the Network. \nNTP should be installed for this to work."; printf "Please wait a few moments while the time is being synchronised..\n"; sudo ntpdate -u pool.ntp.org; echo "Press a key. . ."; read ;;
      5) echo -n "Enter 1 to enable NTP and 0 to disable NTP : "; read ntch; timedatectl set-ntp $ntch; echo "Press a key. . ."; read ;;
      6) sudo systemctl enable ntpd; echo "Press a key. . ."; read ;;      
      7) sudo systemctl disable ntpd; echo "Press a key. . ."; read ;;
      8) echo -n "Enter 0 to set Hardware clock to UTC and 1 to set it to Localtime : "; read rtcch; timedatectl set-local-rtc $rtcch; echo "Press a key. . ."; read ;;
      9) sudo hwclock -D ; echo "Press a key. . ."; read ;; 
      10) sudo hwclock -w ; echo "Press a key. . ."; read ;; 
      11) sudo hwclock -s ; echo "Press a key. . ."; read ;; 
      12) echo -ne "Enter the time.\nThe time may be specified in the format 2012-10-30 18:17:16 . \nOnly hh:mm can also be used. \nEnter time: "; read time; timedatectl set-time $time; echo "Press a key. . ."; read ;;
      q) printf "Thanks for using this script!\n"; exit 0 ;;
      *) echo "Opps!!! Please a valid choice!";#!/bin/bash
         echo "Press a key. . ." ; read ;;
 esac
done
exit 0


-- mod edit: read the Forum Etiquette and only post thumbnails http://wiki.archlinux.org/index.php/For … s_and_Code [jwr] --
       Ok, done. -Aaditya

Last edited by aaditya (2013-11-22 18:44:21)

Offline

#3 2013-11-04 13:40:10

aaditya
Member
Registered: 2013-09-01
Posts: 174

Re: A script to manage system time (+GUI available by Frodouser-senior)

I made a pkgbuild for it and uploaded it to the AUR.
https://aur.archlinux.org/packages/timeset/

Offline

#4 2013-11-22 18:43:54

aaditya
Member
Registered: 2013-09-01
Posts: 174

Re: A script to manage system time (+GUI available by Frodouser-senior)

A GUI has been developed by Frodouser-senior and me.
https://aur.archlinux.org/packages/timeset-gui/
th_timeset-gui-2.png
It installs an icon in Applications -> System

Offline

Board footer

Powered by FluxBB