Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 27 Jul 2016, 03:58
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
alarm clock
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [1 Post]  
Author Message
learnhow2code

Joined: 12 Jun 2016
Posts: 542

PostPosted: Tue 12 Jul 2016, 21:01    Post subject:  alarm clock  

Code:
#!/bin/bash
# figlet-style alarm clock
# license: creative commons cc0 1.0 universal (cc0 1.0)
#   http://creativecommons.org/publicdomain/zero/1.0/
setterm -powersave on
p=""
alarmhour="08"
alarmmin="59"
alarmmeridiem="AM"
alarmon="0"
while [[ "$p" != "itwillnotbethis" ]]
do t=t
clear
read -n 1 -t 10 p
ctime="$(date +%I:%M%p)"
alarmtime="$alarmhour"":$alarmmin""$alarmmeridiem"
if [[ "$p" != "" ]]
  then setterm -blank poke
  clear

    ps=""
    me="4"
    read -n 2 -t 2 ps
    if [[ "$ps" == "ss" ]]
      then echo
      while [[ 1 ]]
        do ps=""
        clear
        echo
        echo " settings mode "   
        echo
        echo
        m1="  " ; m2="  " ; m3="  " ; m4="  " ; m5="  "
        if [[ "$me" == "1" ]] ; then m1="->" ; fi
        if [[ "$me" == "2" ]] ; then m2="->" ; fi
        if [[ "$me" == "3" ]] ; then m3="->" ; fi
        if [[ "$me" == "4" ]] ; then m4="->" ; fi
        if [[ "$me" == "5" ]] ; then m5="->" ; fi
        echo " $m1 1. change hour"
        echo " $m2 2. change minute"
        echo " $m3 3. change am/pm"
        echo
        echo " $m4 4. turn alarm on/off"
        echo
        echo " $m5 5. save & exit settings"
        echo
        echo
        alarmtime="$alarmhour"":$alarmmin""$alarmmeridiem"
        echo " alarm time is: "$alarmtime
        echo
        if [[ "$alarmon" == "1" ]]
          then echo " alarm is on" 
          else echo " alarm is off"
          fi
        echo
        echo
        echo " == arrow  up / DOWN to select from menu  == "
        echo
        echo " == arrow left / RIGHT to change settings == "
       
        read -n 3 -t 2 ps
        ps=$(echo "$ps" | hexdump | cut -c 16-17)


        if [[ "$ps" == "41" ]]
          then me=$(($me-1)) #"up"
          if [[ "$me" -lt "1" ]] ; then me=5 ; fi
          fi
        if [[ "$ps" == "42" ]] 
          then me=$(($me+1)) #"down"
          if [[ "$me" -gt "5" ]] ; then me=1 ; fi
          fi

        if [[ "$ps" == "43" ]] 
          then l=l #"right"

          if [[ "$me" == "1" ]]
            then alarmhour=$(($(echo $alarmhour | sed "s/^0//")+1))
            if [[ "$alarmhour" -gt "12" ]] ; then alarmhour=1 ; fi
            alarmhour="$(echo 0$alarmhour | sed 's/010/10/' | sed 's/011/11/' | sed 's/012/12/')"       
            fi
          if [[ "$me" == "2" ]]
            then alarmmin=$(($(echo $alarmmin | sed "s/^0//")+1))
            if [[ "$alarmmin" -gt "59" ]] ; then alarmmin=0 ; fi
            if [[ "$alarmmin" -lt "10" ]] ; then alarmmin="$(echo 0$alarmmin)" ; fi       
            fi
          if [[ "$me" == "3" ]]
            then if [[ "$alarmmeridiem" == "AM" ]]
              then alarmmeridiem="PM"
              else alarmmeridiem="AM"
              fi
            fi
          if [[ "$me" == "4" ]]
            then if [[ "$alarmon" == "1" ]]
              then alarmon="0"
              else alarmon="1"
              fi
            fi
          if [[ "$me" == "5" ]]
            then break
            fi

          fi

        if [[ "$ps" == "44" ]] 
          then l=l #"left"

          if [[ "$me" == "1" ]]
            then alarmhour=$(($(echo $alarmhour | sed "s/^0//")-1))
            if [[ "$alarmhour" -lt "1" ]] ; then alarmhour=12 ; fi
            alarmhour="$(echo 0$alarmhour | sed 's/010/10/' | sed 's/011/11/' | sed 's/012/12/')"       
            fi
          if [[ "$me" == "2" ]]
            then alarmmin=$(($(echo $alarmmin | sed "s/^0//")-1))
            if [[ "$alarmmin" -lt "0" ]] ; then alarmmin=59 ; fi
            if [[ "$alarmmin" -lt "10" ]] ; then alarmmin="$(echo 0$alarmmin)" ; fi       
            fi
          if [[ "$me" == "3" ]]
            then if [[ "$alarmmeridiem" == "AM" ]]
              then alarmmeridiem="PM"
              else alarmmeridiem="AM"
              fi
            fi
          if [[ "$me" == "4" ]]
            then if [[ "$alarmon" == "1" ]]
              then alarmon="0"
              else alarmon="1"
              fi
            fi
          if [[ "$me" == "5" ]]
            then break
            fi

          fi

        echo ok
        done
      else echo " $ctime" | toilet -f bigascii12 --filter gay
      sleep 10
      fi

  #clear the keyboard buffer
  read -n 1 -t .05 nul ; read -n 1 -t .05 nul ; read -n 1 -t .05 nul ; read -n 1 -t .05 nul ; read -n 1 -t .05 nul 
  read -n 1 -t .05 nul ; read -n 1 -t .05 nul ; read -n 1 -t .05 nul ; read -n 1 -t .05 nul ; read -n 1 -t .05 nul 
  setterm -blank force
  fi
if [[ "$ctime" == "$alarmtime" ]]
  then if [[ "$alarmon" == "1" ]]
    then sleep 60
    mplayer -volume 140 churchbells.mp3 -loop 20
    fi
  clear
  fi
done

_________________
"people werent used to machines doing what theyre supposed to, because they didnt want to learn how to talk to them. the hypnotists tricks amazed and amused. imagine! robots doing exactly what theyre told!" - the robot hypnotist
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [1 Post]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0721s ][ Queries: 11 (0.0088s) ][ GZIP on ]