(I will use it as a reminder to brush each quadrant of my teeth when
using a electric toothbrush.)
I have to say, this is one of the strangest reasons I have ever heard (electric toothbrushes have builtin timers these days) :D ... Probably, you'd prefer your computer to give you spoken instructions as well like so:
{
t=$(date +"%s")
while true
do
n=$(date +"%s")
((n<=(t+30))) && spd-say -w 'Brush Upper Left Quadrant'
((n>(t+30) && n<=(t+60))) && spd-say -w 'Brush Upper Right Quadrant'
((n>(t+60) && n<=(t+90))) && spd-say -w 'Brush Lower Left Quadrant'
((n>(t+90) && n<=(t+120))) && spd-say -w 'Brush Lower Right Quadrant'
((n>(t+120))) && break
done
}
Or make it less chattering like so:
{
f=(
'Brush Upper Left Quadrant'
'Brush Upper Right Quadrant'
'Brush Lower Left Quadrant'
'Brush Lower Right Quadrant'
'Congratulations, mission accomplished'
)
for i in {0..4}
do
spd-say -w "${f[$i]}"
[ "$i" -lt 4 ] && sleep 30
done
}
Or use the timeout
command with your player and audio files like so:
{
timeout 30 mpg123 --loop -1 /usr/share/sounds/My_Sounds/Alarm_Clock_Sound.mp3
timeout 30 mpg123 --loop -1 /usr/share/sounds/My_Sounds/Alarm-sound-buzzer.mp3
timeout 30 mpg123 --loop -1 /usr/share/sounds/My_Sounds/Alarm_Clock_Sound.mp3
timeout 30 mpg123 --loop -1 /usr/share/sounds/My_Sounds/Alarm-sound-buzzer.mp3
}
or with sleep
and the Bash builtin kill
like so:
{
f=(
'/usr/share/sounds/My_Sounds/Alarm_Clock_Sound.mp3'
'/usr/share/sounds/My_Sounds/Alarm-sound-buzzer.mp3'
'/usr/share/sounds/My_Sounds/Alarm_Clock_Sound.mp3'
'/usr/share/sounds/My_Sounds/Alarm-sound-buzzer.mp3'
)
for i in {0..3}
do
mpg123 --loop -1 "${f[$i]}" &> /dev/null & p="$!"
sleep 30
kill "$p"
done
}
Or play each file once then wait 30 seconds and move on to the next file like so:
{
f=(
'/usr/share/sounds/My_Sounds/Alarm_Clock_Sound.mp3'
'/usr/share/sounds/My_Sounds/Alarm-sound-buzzer.mp3'
'/usr/share/sounds/My_Sounds/Alarm_Clock_Sound.mp3'
'/usr/share/sounds/My_Sounds/Alarm-sound-buzzer.mp3'
)
for i in {0..3}
do
mpg123 "${f[$i]}" &> /dev/null
[ "$i" -lt 3 ] && sleep 30
done
}
mpg123
has a--loop
feature which allows you to repeat the play a specified number of times, ie. if the MP3 file you're using goes for 10 seconds,--loop 3
may have it play for 30 seconds. – guiverc Nov 25 '23 at 05:51