You are not logged in.

#1 2009-11-21 09:01:56

Odysseus
Member
Registered: 2009-02-15
Posts: 141

Super simple bash music player

I've got this little script that continuously plays random songs:

#!/bin/sh

songs=(~/music/*/*/*)
total=${#songs[@]}

while true
do
    song=${songs[$RANDOM%$total]}
    oggdec "$song" -o- | aplay -q
done

I'd like to be able to skip a song and go to the next, aside from a ctrl-c and restart. Suggestions?

Last edited by Odysseus (2009-11-21 09:04:09)


I'm the type to fling myself headlong through the magical wardrobe, and then incinerate the ornate mahogany portal behind me with a Molotov cocktail.

Offline

#2 2009-11-21 17:29:39

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: Super simple bash music player

If the script isn't to be run in background then may be you can keep the while loop in background, and use read to get a response,e.g. if it is "n" then terminate the while loop and restart with array index increased by 1
But if you'd like to run it in the background, you can use trapping of signals may be

Last edited by djszapi (2009-11-21 17:36:38)

Offline

#3 2009-11-22 19:15:19

Odysseus
Member
Registered: 2009-02-15
Posts: 141

Re: Super simple bash music player

Ehh, I think I'm gonna go all out with something written in python using gstreamer and gtk...I'd love to be able to use my media keys smile

Last edited by Odysseus (2009-11-22 19:15:59)


I'm the type to fling myself headlong through the magical wardrobe, and then incinerate the ornate mahogany portal behind me with a Molotov cocktail.

Offline

Board footer

Powered by FluxBB