I have created a KornShell (ksh) script that plays a list of songs on youtube by searching the song name + the artist name and hitting the first link (the list of song names and artists are stored in a file).
I would like to change my current approach of having the user enter some value (read x < /dev/tty) on the terminal to play the next song. I want the script to simply switch over to the next song as soon as the first one stops playing. While I am aware that the approach may have caveats (what if another sound starts and stops while the song is still playing) - this would still meet my basic requirements. Any ideas on how to poll the sound card through shell?