Last active
February 25, 2016 06:49
-
-
Save oyakodon/3502e1037a70b48b32c2 to your computer and use it in GitHub Desktop.
時報シェルスクリプト / Bash & AquesTalkPi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# http://oykdn.hatenablog.com/entry/2016/02/24/231148 | |
# <ゆっくりに時刻を言わせる> | |
HOUR=`date '+%l' | tr -d ' '` # 時刻の取得 | |
AMPM=`date '+%p'` # 午前 or 午後 | |
# 午前か午後かで分岐 | |
if [ $AMPM = "AM" ]; then | |
AMPM="ごぜん" | |
else | |
AMPM="ごご" | |
fi | |
# 数字に対応する日本語の配列 | |
arr_hour=("いち" "に" "さん" "よ" "ご" "ろく" "しち" "はち" "く" "じゅう" "じゅういち" "れい") | |
HOUR=${arr_hour[$HOUR % 12]} | |
WORDS="${AMPM},${HOUR}じぐらいを,おしらせします。" | |
/usr/local/bin/AquesTalkPi $WORDS | aplay -D plughw:1,0 | |
# <時報音を鳴らす> | |
# 事前に「/home/pi/」に「jiho.mp3」というファイル名の時報音を置いておいてください。 | |
mplayer /home/pi/jiho.mp3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment