LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-14-2008, 01:30 AM   #1
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Rep: Reputation: 33
xargs, mplayer loses key controls


Code:
ls -1 *mp3 | tail -n2 | xargs -I{} mplayer {}
So I'm looking for just about any excuse to learn the cli. This lists mp3's in the dir, selects the last two, and feeds them one by one into mplayer (correct me if I'm wrong..). It works, as far as hearing the right music come out of the speakers. But none of the keyboard controls work when I use this. If I just run 'mplayer track11.mp3', all's well. I can mute, seek, stop, etc.

Anyone know what's wrong?
 
Old 04-14-2008, 03:45 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 64
The difference is that when you run with xargs, the program you are running does not get connected to the terminal in which you are running it. Consider this example:
Code:
$ cat test.sh
#!/bin/bash
echo "The terminal is: $(tty)"

$ chmod 755 test.sh
$ ./test.sh
The terminal is: /dev/pts/1
$ echo "oh hai" | xargs ./test.sh
The terminal is: not a tty
It seems mplayer behaves differently when connected to a terminal compared to when it's not. I can replicate this. What's weird is that with movie files it is not the case. I suspect that when playing video the key press events are handled by the X-window which is created where as with audio only files there is no X-window, and so keypress events can only work if the process is attached to a tty from which to get input.

One solution if your file names do not have spaces in them, try this:
Code:
mplayer $(ls *mp3 | tail -n2)
By the way the -I{} and {} are not necessary in your original command, and the -1 option to ls is also not necessary (when ls is not connected to a terminal, it always lists in a single column format, assuming that it is part of a pipeline.
 
Old 04-14-2008, 04:16 AM   #3
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Original Poster
Rep: Reputation: 33
That certainly explains things. Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SCO loses court case key to Linux future DragonSlayer48DX Linux - News 0 08-13-2007 05:07 AM
quick question: Key controls for compiz? 144419855310001 General 3 06-14-2007 12:02 PM
Mplayer controls lowbrow Linux - Newbie 3 06-07-2005 11:22 AM
MPlayer controls appear off screen ohzo Linux - Newbie 2 07-15-2004 08:03 PM
Mplayer issue...I have no controls.... oicdn Linux - Software 15 12-25-2003 08:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration