The Following User Says Thank You to lemmyslender For This Useful Post: | ||
|
2011-03-16
, 22:40
|
Posts: 569 |
Thanked: 462 times |
Joined on Jul 2010
@ USA
|
#442
|
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.
|
2011-03-17
, 12:36
|
Posts: 968 |
Thanked: 974 times |
Joined on Nov 2008
@ Ohio
|
#443
|
#! /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
#! /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
checklate=`date +%H` #skip chimes if nightime (between 9PM and 5:59AM) if [ $checklate -lt 21 ]; then if [ $checklate -gt 5 ]; then
fi fi
The Following User Says Thank You to lemmyslender For This Useful Post: | ||
|
2011-03-17
, 16:46
|
Posts: 4 |
Thanked: 4 times |
Joined on Dec 2010
@ Budapest
|
#444
|
|
2011-03-18
, 02:31
|
Posts: 569 |
Thanked: 462 times |
Joined on Jul 2010
@ USA
|
#445
|
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
|
2011-03-18
, 02:45
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#446
|
|
2011-03-18
, 12:00
|
Posts: 968 |
Thanked: 974 times |
Joined on Nov 2008
@ Ohio
|
#447
|
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:
Does the 'exit" command exit the shell script, or just a 'for' loop?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
|
2011-03-18
, 13:25
|
Posts: 74 |
Thanked: 25 times |
Joined on Jan 2010
@ Hong Kong, CHINA
|
#448
|
...
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
The Following User Says Thank You to mdengler For This Useful Post: | ||
|
2011-03-18
, 16:05
|
|
Posts: 129 |
Thanked: 11 times |
Joined on Feb 2010
@ Bangalore, India
|
#449
|
|
2011-03-18
, 16:25
|
Posts: 89 |
Thanked: 52 times |
Joined on Jan 2010
@ London, UK
|
#450
|
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.
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:
Does the 'exit" command exit the shell script, or just a 'for' loop?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
checklate=`date +%H` #skip chimes if nightime (between 9PM and 5:59AM) if [ $checklate -gt 21 -a $checklate -lt 5 ]; then exit 1 fi
[ $checklate -gt 21 -a $checklate -lt 5 ] && exit 1
The Following User Says Thank You to jgbreezer For This Useful Post: | ||
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.
*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