You are not logged in.
I was just fulling with some bash script in order to automate the listening of my favorite radio stations via mplayer and a bash script. Going through the mplayers manual I saw the option -slave.
-slave
This option switches on slave mode. This is intended for use of MPlayer as a backend to other programs. Instead of intercepting keyboard events, MPlayer will read simplistic command lines from its stdin. The section SLAVE MODE PROTOCOL explains the syntax.
At first I thought "ok, easy". I made some tries like "mplayer -slave -quiet .... < /tmp/stdin &" and then something like "echo -e 'mute' > /tmp/stdin" but it wouldn't work.
Is it possible to send a process to the background inside a bash script and then write to it's stdin?
SLAVE MODE PROTOCOL
If the -slave option is given, playback is controlled by a line-based protocol. Each line must contain one command otherwise one of the following tokens:
Commands
seek <value> [type=<0/:1/:2>]
Seek to some place in the movie. Type 0 is a relative seek of +/:- <value> seconds. Type 1 seek to <value> % in the movie. Type 2 is a seek to an absolute position of <value> seconds.
audio_delay <value>
Adjust the audio delay of value seconds
quit
Quit MPlayer
pause
Pause/:unpause the playback
grap_frames
Somebody know ?
pt_step <value> [force=<value>]
Go to next/:previous entry in the playtree.
pt_up_step <value> [force=<value>]
Like pt_step but it jumps to next/:previous in the parent list.
alt_src_step <value>
When more than one source is available it selects the next/:previous one (only supported by asx playlist).
sub_delay <value> [abs=<value>]
Adjust the subtitles delay of +/:- <value> seconds or set it to <value> seconds when abs is non zero.
osd [level=<value>]
Toggle osd mode or set it to level when level > 0.
volume <dir>
Increase/:decrease volume
[contrast|brightness|hue|saturation] <-100-100> [abs=<value>]
Set/:Adjust video parameters.
frame_drop [type=<value>]
Toggle/:Set frame dropping mode.
sub_visibility
Toggle subtitle visibility.
sub_pos <value>
Adjust subtitles position.
vo_fullscreen
Switch to fullscreen mode.
tv_step_channel <dir>
Select next/:previous tv channel.
tv_step_norm
Change TV norm.
tv_step_chanlist
Change channel list.
gui_[loadsubtitle|about|play|stop]
Γίνε ρεαλιστής, μείνε ονειροπόλος ...
Offline
Offline
Yes it worked just fine for mplayer. Thanks you.
mkfifo is the way to go for other programs too?
Γίνε ρεαλιστής, μείνε ονειροπόλος ...
Offline
Yes it worked just fine for mplayer. Thanks you.
mkfifo is the way to go for other programs too?
I think 'man mkfifo' will answer that question :-)
Offline
FIFO's are awesome and can be (ab)used for a lot of cool stuff.
I've written some applications that do just what you are trying to do ( http://github.com/trapd00r/rmcd and http://github.com/trapd00r/RPD ), if you need inspiration.
As for the backgrounding - you want to make a 'daemon', to detach from the running shell. See man fork, man 3 setsid and man 3 wait / man 3 waitpid (or my daemonize() function).
Offline
Thanks you very much!!!
Γίνε ρεαλιστής, μείνε ονειροπόλος ...
Offline