Created
February 7, 2023 06:47
-
-
Save MasWag/711b61ff7332bf4a6eab5151b2eeb06e to your computer and use it in GitHub Desktop.
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 -u | |
function finish { | |
hours=$((elapsed / 3600)) | |
minutes=$(((elapsed % 3600) / 60)) | |
seconds=$((elapsed % 60)) | |
if [ $hours -gt 0 ]; then | |
time_string="$hours 時間 $minutes 分 $seconds 秒" | |
elif [ $minutes -gt 0 ]; then | |
time_string="$minutes 分 $seconds 秒" | |
else | |
time_string="$seconds 秒" | |
fi | |
say -v Kyoko "$time_string です" | |
} | |
trap finish EXIT | |
start=$(date +%s) | |
echo "Press [CTRL+C] to stop.." | |
while true; do | |
clear | |
current=$(date +%s) | |
elapsed=$((current - start)) | |
hours=$((elapsed / 3600)) | |
minutes=$(((elapsed % 3600) / 60)) | |
seconds=$((elapsed % 60)) | |
printf "%02d:%02d:%02d\n" $hours $minutes $seconds | |
if [ $minutes -gt 0 ] && [ $((minutes % 5)) -eq 0 ] && [ $seconds -lt 2 ]; then | |
say -v Kyoko "$minutes 分です" | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment