Raja G
Raja G

Reputation: 6643

How to send arguments to process running in the background?

I wrote a small shell script that plays music when ever I call it.

function playmusic() {
  find /music/path -type f -name "*.mp3" -exec mplayer {} \;
}

and added it to my .zshrc file, so now I can play music by calling playmusic.

If I am working with multiple tabs I had to search the tab where I am playing the music, but if I know how can I send arguments to playmusic function PID then I can control it from any terminal.

any suggestions greatly appreciated.

Thank you.

Upvotes: 0

Views: 101

Answers (1)

jhnc
jhnc

Reputation: 16761

You can use slave mode: http://www.mplayerhq.hu/DOCS/tech/slave.txt

For example:

mkfifo ~/.mplayer/fifo

function playmusic(){
    find /music/path -type -name "*.mp3" -exec \
    mplayer -really-quiet -slave -input file=~/.mplayer/fifo {} \;
}

function mmute(){
    echo m > ~/.mplayer/fifo
}
function mquit(){
    echo q > ~/.mplayer/fifo
}

Upvotes: 2

Related Questions