Active Topics

 



Notices


Reply
Thread Tools
Posts: 968 | Thanked: 974 times | Joined on Nov 2008 @ Ohio
#441
@ rotoflex

Thought the idea of clock chimes interesting, so I wrote a script that will check the time and play the proper sound files. You just need to set 4 alarms each running the script at :00, :15, :30, :45.

Brute force, but it works. I didn't see an option in alarmed to run every 15 minutes, although somebody should be able to construct the proper cron syntax, which would get it down to 1 alarm.

Code:
#! /bin/bash

checkhour=`date +%H`
checkmin=`date +%M`
#echo $checkhour:$checkmin

if [ $checkmin -eq 00 ]; then
if [ $checkhour -eq 1 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord01-45db.wav
fi
if [ $checkhour -eq 2 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
fi
if [ $checkhour -eq 3 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord03-45db.wav
fi
if [ $checkhour -eq 4 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord04-45db.wav
fi
if [ $checkhour -eq 5 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord05-45db.wav
fi
if [ $checkhour -eq 6 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord06-45db.wav
fi
if [ $checkhour -eq 7 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord07-45db.wav
fi
if [ $checkhour -eq 8 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord08-45db.wav
fi
if [ $checkhour -eq 9 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord09-45db.wav
fi
if [ $checkhour -eq 10 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord10-45db.wav
fi
if [ $checkhour -eq 11 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord11-45db.wav
fi
if [ $checkhour -eq 12 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord12-45db.wav
fi
if [ $checkhour -eq 13 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour01-45db.wav
fi
if [ $checkhour -eq 14 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour02-45db.wav
fi
if [ $checkhour -eq 15 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour03-45db.wav
fi
if [ $checkhour -eq 16 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour04-45db.wav
fi
if [ $checkhour -eq 17 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour05-45db.wav
fi
if [ $checkhour -eq 18 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour06-45db.wav
fi
if [ $checkhour -eq 19 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour07-45db.wav
fi
if [ $checkhour -eq 20 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour08-45db.wav
fi
if [ $checkhour -eq 21 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour09-45db.wav
fi
if [ $checkhour -eq 22 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour10-45db.wav
fi
if [ $checkhour -eq 23 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour11-45db.wav
fi
if [ $checkhour -eq 0 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour12-45db.wav
fi
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang1Q-45db.wav
fi
if [ $checkmin -eq 15 ]; then
if [ $checkhour -eq 1 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord01-45db.wav
fi
if [ $checkhour -eq 2 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
fi
if [ $checkhour -eq 3 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord03-45db.wav
fi
if [ $checkhour -eq 4 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord04-45db.wav
fi
if [ $checkhour -eq 5 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord05-45db.wav
fi
if [ $checkhour -eq 6 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord06-45db.wav
fi
if [ $checkhour -eq 7 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord07-45db.wav
fi
if [ $checkhour -eq 8 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord08-45db.wav
fi
if [ $checkhour -eq 9 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord09-45db.wav
fi
if [ $checkhour -eq 10 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord10-45db.wav
fi
if [ $checkhour -eq 11 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord11-45db.wav
fi
if [ $checkhour -eq 12 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord12-45db.wav
fi
if [ $checkhour -eq 13 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour01-45db.wav
fi
if [ $checkhour -eq 14 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour02-45db.wav
fi
if [ $checkhour -eq 15 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour03-45db.wav
fi
if [ $checkhour -eq 16 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour04-45db.wav
fi
if [ $checkhour -eq 17 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour05-45db.wav
fi
if [ $checkhour -eq 18 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour06-45db.wav
fi
if [ $checkhour -eq 19 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour07-45db.wav
fi
if [ $checkhour -eq 20 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour08-45db.wav
fi
if [ $checkhour -eq 21 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour09-45db.wav
fi
if [ $checkhour -eq 22 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour10-45db.wav
fi
if [ $checkhour -eq 23 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour11-45db.wav
fi
if [ $checkhour -eq 0 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour12-45db.wav
fi
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang2Q-45db.wav
fi
if [ $checkmin -eq 30 ]; then
if [ $checkhour -eq 1 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord01-45db.wav
fi
if [ $checkhour -eq 2 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
fi
if [ $checkhour -eq 3 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord03-45db.wav
fi
if [ $checkhour -eq 4 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord04-45db.wav
fi
if [ $checkhour -eq 5 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord05-45db.wav
fi
if [ $checkhour -eq 6 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord06-45db.wav
fi
if [ $checkhour -eq 7 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord07-45db.wav
fi
if [ $checkhour -eq 8 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord08-45db.wav
fi
if [ $checkhour -eq 9 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord09-45db.wav
fi
if [ $checkhour -eq 10 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord10-45db.wav
fi
if [ $checkhour -eq 11 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord11-45db.wav
fi
if [ $checkhour -eq 12 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord12-45db.wav
fi
if [ $checkhour -eq 13 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour01-45db.wav
fi
if [ $checkhour -eq 14 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour02-45db.wav
fi
if [ $checkhour -eq 15 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour03-45db.wav
fi
if [ $checkhour -eq 16 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour04-45db.wav
fi
if [ $checkhour -eq 17 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour05-45db.wav
fi
if [ $checkhour -eq 18 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour06-45db.wav
fi
if [ $checkhour -eq 19 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour07-45db.wav
fi
if [ $checkhour -eq 20 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour08-45db.wav
fi
if [ $checkhour -eq 21 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour09-45db.wav
fi
if [ $checkhour -eq 22 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour10-45db.wav
fi
if [ $checkhour -eq 23 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour11-45db.wav
fi
if [ $checkhour -eq 0 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour12-45db.wav
fi
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang3Q-45db.wav
fi
if [ $checkmin -eq 45 ]; then
if [ $checkhour -eq 1 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord01-45db.wav
fi
if [ $checkhour -eq 2 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
fi
if [ $checkhour -eq 3 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord03-45db.wav
fi
if [ $checkhour -eq 4 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord04-45db.wav
fi
if [ $checkhour -eq 5 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord05-45db.wav
fi
if [ $checkhour -eq 6 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord06-45db.wav
fi
if [ $checkhour -eq 7 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord07-45db.wav
fi
if [ $checkhour -eq 8 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord08-45db.wav
fi
if [ $checkhour -eq 9 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord09-45db.wav
fi
if [ $checkhour -eq 10 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord10-45db.wav
fi
if [ $checkhour -eq 11 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord11-45db.wav
fi
if [ $checkhour -eq 12 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord12-45db.wav
fi
if [ $checkhour -eq 13 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour01-45db.wav
fi
if [ $checkhour -eq 14 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour02-45db.wav
fi
if [ $checkhour -eq 15 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour03-45db.wav
fi
if [ $checkhour -eq 16 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour04-45db.wav
fi
if [ $checkhour -eq 17 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour05-45db.wav
fi
if [ $checkhour -eq 18 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour06-45db.wav
fi
if [ $checkhour -eq 19 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour07-45db.wav
fi
if [ $checkhour -eq 20 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour08-45db.wav
fi
if [ $checkhour -eq 21 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour09-45db.wav
fi
if [ $checkhour -eq 22 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour10-45db.wav
fi
if [ $checkhour -eq 23 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour11-45db.wav
fi
if [ $checkhour -eq 0 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour12-45db.wav
fi
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang4Q-45db.wav
fi
That chimes the hour then the quarter hour. I modified the one I'm using to only chime the hour at the top of the hour, and only chime the quarters for the 15/30/45.
__________________
*Consumer*, not a developer! I apologize for any inconvenience.
My script to backup /home and /opt
Samsung Galaxy S Vibrant, Huawei S7, N900(retired), N800(retired)

Last edited by lemmyslender; 2011-03-16 at 17:29. Reason: typo in code
 

The Following User Says Thank You to lemmyslender For This Useful Post:
Posts: 569 | Thanked: 462 times | Joined on Jul 2010 @ USA
#442
Originally Posted by lemmyslender View Post
I modified the one I'm using to only chime the hour at the top of the hour, and only chime the quarters for the 15/30/45.
That's what I do, like a regular chiming clock.

Did you modify it by having the script only check & play the hours, calling the script at the top of the hour; & adding an additional 3 alarmd events at the quarters to call only 15, 30, or 45 specifically?

That seems like a useful approach for others: they can just run the script hourly for a top of the hour chime, and then have the option for adding the quarters (or deleting the events for the quarters, if they can't handle chimes every 15 minutes).

Last edited by rotoflex; 2011-03-16 at 22:46.
 
Posts: 968 | Thanked: 974 times | Joined on Nov 2008 @ Ohio
#443
I modified the script, although as you point out, you can just set your quarterly chimes directly. For quarterly chimes, you'd need 4 alarms, but as you point out, you can eliminate any of them (ie hourly only, hourly / half hour, quarters).

Code for hourly chime at :00 and quarterly chimes only at :15, :30, :45

Code:
#! /bin/bash

checkhour=`date +%H`
checkmin=`date +%M`
#echo $checkhour:$checkmin

if [ $checkmin -eq 00 ]; then
if [ $checkhour -eq 1 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord01-45db.wav
fi
if [ $checkhour -eq 2 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
fi
if [ $checkhour -eq 3 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord03-45db.wav
fi
if [ $checkhour -eq 4 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord04-45db.wav
fi
if [ $checkhour -eq 5 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord05-45db.wav
fi
if [ $checkhour -eq 6 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord06-45db.wav
fi
if [ $checkhour -eq 7 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord07-45db.wav
fi
if [ $checkhour -eq 8 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord08-45db.wav
fi
if [ $checkhour -eq 9 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord09-45db.wav
fi
if [ $checkhour -eq 10 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord10-45db.wav
fi
if [ $checkhour -eq 11 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord11-45db.wav
fi
if [ $checkhour -eq 12 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord12-45db.wav
fi
if [ $checkhour -eq 13 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour01-45db.wav
fi
if [ $checkhour -eq 14 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour02-45db.wav
fi
if [ $checkhour -eq 15 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour03-45db.wav
fi
if [ $checkhour -eq 16 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour04-45db.wav
fi
if [ $checkhour -eq 17 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour05-45db.wav
fi
if [ $checkhour -eq 18 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour06-45db.wav
fi
if [ $checkhour -eq 19 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour07-45db.wav
fi
if [ $checkhour -eq 20 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour08-45db.wav
fi
if [ $checkhour -eq 21 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour09-45db.wav
fi
if [ $checkhour -eq 22 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour10-45db.wav
fi
if [ $checkhour -eq 23 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour11-45db.wav
fi
if [ $checkhour -eq 0 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtangHour12-45db.wav
fi
fi
if [ $checkmin -eq 15 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang2Q-45db.wav
fi
if [ $checkmin -eq 30 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang3Q-45db.wav
fi
if [ $checkmin -eq 45 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang4Q-45db.wav
fi
And just for fun, for those with a nautical flair (in honor of my brother who got his 1600 ton captains license earlier this week) chimes for a ships clock / ships watches. (only needs 2 alarms :00 and :30, but will work even if you have all 4 quarterly scheduled)
Code:
#! /bin/bash

checkhour=`date +%I`
checkmin=`date +%M`

#Change hours to watches
if [ $checkhour -eq 4 ]; then
  checkhour=12
fi
if [ $checkhour -eq 8 ]; then
  checkhour=12
fi
if [ $checkhour -eq 5 ]; then
  checkhour=1
fi
if [ $checkhour -eq 9 ]; then
  checkhour=1
fi
if [ $checkhour -eq 6 ]; then
  checkhour=2
fi
if [ $checkhour -eq 10 ]; then
  checkhour=2
fi
if [ $checkhour -eq 7 ]; then
  checkhour=3
fi
if [ $checkhour -eq 11 ]; then
  checkhour=3
fi

#sound bells
if [ $checkmin -eq 00 ]; then
  if [ $checkhour -eq 12 ]; then
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
  fi
  if [ $checkhour -eq 1 ]; then
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
  fi
  if [ $checkhour -eq 2 ]; then
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
  fi
  if [ $checkhour -eq 3 ]; then
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
  fi
fi
if [ $checkmin -eq 30 ]; then
  if [ $checkhour -eq 12 ]; then
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord01-45db.wav
  fi
  if [ $checkhour -eq 1 ]; then
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord01-45db.wav
  fi
  if [ $checkhour -eq 2 ]; then
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord01-45db.wav
  fi
  if [ $checkhour -eq 3 ]; then
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord02-45db.wav
    sleep 1
    play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord01-45db.wav
  fi
fi
Later, I'll probably modify the script so that it doesn't chime between 10PM and 6AM.

Add these lines at the beginning of the script
Code:
checklate=`date +%H`
#skip chimes if nightime (between 9PM and 5:59AM)
if [ $checklate -lt 21 ]; then
  if [ $checklate -gt 5 ]; then
and at the end of the script add
Code:
  fi
fi
that should keep it from chiming at/after 9PM and before 6AM. Uses a 24 hour clock to check (21=9pm, 5=5am) change to suit your needs.
__________________
*Consumer*, not a developer! I apologize for any inconvenience.
My script to backup /home and /opt
Samsung Galaxy S Vibrant, Huawei S7, N900(retired), N800(retired)

Last edited by lemmyslender; 2011-03-17 at 13:06. Reason: added code for preventing late chimes.
 

The Following User Says Thank You to lemmyslender For This Useful Post:
Posts: 4 | Thanked: 4 times | Joined on Dec 2010 @ Budapest
#444
Hi, I modified alarmed to include better cron syntax, so with the latest version you can write Cron String " */15 8-18 * * * " to call the chim in every quarter from 8AM to 6PM.
 

The Following 2 Users Say Thank You to hunludvig For This Useful Post:
Posts: 569 | Thanked: 462 times | Joined on Jul 2010 @ USA
#445
lemmyslender:

I am not familiar with linux shell scripts, but looking at the Wikipedia page to see if your "silent" addition could be compacted into one code block instead of 2 if statements wrapping at the top & bottom, would this do the same if it were at the beginning of the script:

Code:
checklate=`date +%H`
#skip chimes if nightime (between 9PM and 5:59AM)
if [ $checklate -gt 21 ]; then
  if [ $checklate -lt 5 ]; then
    exit 1
  fi
fi
Does the 'exit" command exit the shell script, or just a 'for' loop?

Last edited by rotoflex; 2011-03-18 at 02:34.
 
Posts: 1,425 | Thanked: 983 times | Joined on May 2010 @ Hong Kong
#446
My apology if this issue has been raised before.

The original alarmd could ring alarm even when the device is shutdown. It's so useful in many occasion.

However, it seems that the alarm scheduled by alarmed cannot wake the device from shutdown.

Is there any workaround here? Please kindly advise.
 
Posts: 968 | Thanked: 974 times | Joined on Nov 2008 @ Ohio
#447
Originally Posted by rotoflex View Post
lemmyslender:

I am not familiar with linux shell scripts, but looking at the Wikipedia page to see if your "silent" addition could be compacted into one code block instead of 2 if statements wrapping at the top & bottom, would this do the same if it were at the beginning of the script:

Code:
checklate=`date +%H`
#skip chimes if nightime (between 9PM and 5:59AM)
if [ $checklate -gt 21 ]; then
  if [ $checklate -lt 5 ]; then
    exit 1
  fi
fi
Does the 'exit" command exit the shell script, or just a 'for' loop?
I believe that will work (my scripting skills are pretty basic). It should just exit out (I think you can just use "exit" don't need the 1). I'm pretty there's better (or shorter) ways to do it, they're just beyond the scope of my skill at the moment. I took what I know, threw it together, it worked, tada!
__________________
*Consumer*, not a developer! I apologize for any inconvenience.
My script to backup /home and /opt
Samsung Galaxy S Vibrant, Huawei S7, N900(retired), N800(retired)
 
Posts: 74 | Thanked: 25 times | Joined on Jan 2010 @ Hong Kong, CHINA
#448
Changing the date +%H to date +%I can remove a lot of repetition:

Originally Posted by lemmyslender View Post
...
Code for hourly chime at :00 and quarterly chimes only at :15, :30, :45

Code:
#! /bin/bash

checkhour=`date +%I`
checkmin=`date +%M`
#echo $checkhour:$checkmin

if [ $checkmin -eq 00 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tangstrikechord${checkhour}-45db.wav
fi

if [ $checkmin -eq 15 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang2Q-45db.wav
fi
if [ $checkmin -eq 30 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang3Q-45db.wav
fi
if [ $checkmin -eq 45 ]; then
play-sound /home/user/MyDocs/.sounds/ClockChimes/tingtang4Q-45db.wav
fi
I'm not sure you need /bin/bash - /bin/sh would seem to be sufficient.
 

The Following User Says Thank You to mdengler For This Useful Post:
normaltusker's Avatar
Posts: 129 | Thanked: 11 times | Joined on Feb 2010 @ Bangalore, India
#449
I am not sure if this has been addressed earlier but then my search effort did not yield any results.
After i did a complete reflash of my device including eMMC, my alarmed does not change profiles as per schedule as expected. It changes the profile on a mind of its own. It used to work perfectly fine earlier but it does not now.

Just as an addendum, I did not restore anything other than my contacts and calendar after the reflash. Can some one please help me out?
 
Posts: 89 | Thanked: 52 times | Joined on Jan 2010 @ London, UK
#450
Originally Posted by mdengler View Post
Changing the date +%H to date +%I can remove a lot of repetition:

I'm not sure you need /bin/bash - /bin/sh would seem to be sufficient.
Yes, "sh" is the standard unless you NEED features from bash; sh is faster, and probably one is a symlink to the other anyway on most Linux installs nowadays.

Now for the 2nd simplification..
-----------------------------------------------------------

Originally Posted by rotoflex View Post
lemmyslender:

I am not familiar with linux shell scripts, but looking at the Wikipedia page to see if your "silent" addition could be compacted into one code block instead of 2 if statements wrapping at the top & bottom, would this do the same if it were at the beginning of the script:

Code:
checklate=`date +%H`
#skip chimes if nightime (between 9PM and 5:59AM)
if [ $checklate -gt 21 ]; then
  if [ $checklate -lt 5 ]; then
    exit 1
  fi
fi
Does the 'exit" command exit the shell script, or just a 'for' loop?
Well, 1st, "exit" command exits the script. To exit the "for" loop you need a "break" (just like in C or python or java or ... many others).

2nd, two "if... then.." inside each other with no other code between the if's or fi's can be simplified into just one "if". The inside code only gets executed if condition 1 AND condition 2 are true, so you can join them with an "AND" to get:

Code:
checklate=`date +%H`
#skip chimes if nightime (between 9PM and 5:59AM)
if [ $checklate -gt 21 -a $checklate -lt 5 ]; then
    exit 1
fi
(the "-a" means "and", there is also "-o" for "or" if you need it - as long as each expression is a 'test' expression (see man page/docs for "test" or the equivalent version builtin to many shells)).

You could also have used [ $checklate -gt 21 ] && [ $checklate -lt 5 ] which is the one to use if each condition is a command instead of a square-bracketed-expression. But joining them inside the square brackets with -a doesn't involve so much work for the shell (though not by a lot).

You could even merge the whole if/then/fi block into one line and one full command, using an '&&' because && will only run the later command(s) if the earlier one finishes successfully:

Code:
[ $checklate -gt 21 -a $checklate -lt 5 ] && exit 1
Though I try not to do that because it usually tends to obfuscate things and make it harder to read.

PS for a challenge, "[ $checklate -gt 21 -a $checklate -lt 5 ] && ( exit 1 )" (note the extra brackets) will never exit the script early - do who knows why?

Last edited by jgbreezer; 2011-03-18 at 16:32. Reason: clarity of 'if' as my grammar and "if" used as shell command
 

The Following User Says Thank You to jgbreezer For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 09:11.