I'm playing around with the command line interface of mplayer. I'd like to script it in the following wayfind /some/path/ -type f | grep -vif blacklist | mplayer -shuffle -playlist -where blacklist is a text file with artist or song names I'd rather ignore when I have visitors or my son is around (lot's of swear words... :D)When mplayer encounters the - character, it disables the console input. From the man page:-noconsolecontrols          Prevent MPlayer from reading key events from standard input.            Useful when reading data from standard input.  This is automatically            enabled when - is found on the command line. [snip]This blocks me from seeking in the file and skipping individual songs. Funnily, this works for videos, because the video window still accepts the usual keyboard inputs.How can I have the regular console input back? I would like to avoid using a temporary file, although this is of course the easiest solution. -slave and -input don't seem suited and trying -consolecontroles does not work.
How can I retain the console input in mplayer when reading from stdin?
shell script;grep;pipe;console;mplayer
Feed the input on a file descriptor other than standard input.find /some/path/ -type f | grep -vif blacklist |mplayer -shuffle -playlist /dev/fd/3 3<&0 </dev/ttyExplanation of the last line: the data from grep is coming in on standard input, which is file descriptor 0. There's no way to pipe to anywhere but standard input in the shell, but we can do a bit of extra plumbing. First, we connect file descriptor 3 to wherever file descriptor 0 is: 3<&0. Then we connect file descriptor 0 (i.e. standard input) to the terminal: </dev/tty. We tell mplayer to read the playlist from file descriptor 3; mplayer expects a file name, so we pass it /dev/fd/3, which when opened by a process behaves just like file descriptor 3 in that process at that point.Note that the order of redirections is important, and counterintuitive if you have the wrong intuition. 3<&0 </dev/tty has fd 3 read from where fd 0 read before, and fd 0 read from /dev/tty. </dev/tty 3<&0 would have both fd 0 and fd 3 read from /dev/tty.