Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Here's my boggle. I use gmplayer to play all my videos. 99.9% of the time everything works fine but in that 1-in-1000 case, a video might be corrupted. gmplayer plays the video but it cries like an angry, hungry baby, popping up windows left, right and centre. In really bad videos this actually slows down the whole system as it spawns hundreds of error windows (compiz applies effects, etc). It also steals focus and occasionally cancels Christmas.

In the command-line mplayer these messages are just throw out to the command line. Using mplayer-proper might be an option if I can't use gmplayer but it's not quite as good for my needs.

I have found a workaround. If you add -msglevel all=0 to the gmplayer call, errors are suppressed. Useless from a debug perspective but I'm not attempting to debug videos here, just watch them.

What I want to do is "alias" or "proxy" the gmplayer command so when you run gmplayer from the command line or by association, it actually runs gmplayer -msglevel all=0. I gather that just adding a bash alias won't work for associated (as in double clicking on a video in gnome) plays.

What are my options for hard-proxying the command. This only needs to work for one user but I'm open to system-wide changes too.

share|improve this question
    
excellent question. –  myusuf3 Aug 25 '10 at 14:42
add comment

6 Answers

up vote 8 down vote accepted

You can set this option in one f the mplayer option files, this will then be the default behaviour. For system wide change /etc/mplayer/mpplayer.conf of just for that user create ~/.mplayer/mplayer.conf and put it in there.

Adding this to ~/.mplayer/mplayer.conf works:

msglevel=all=0
share|improve this answer
1  
any idea if it's the same config file for mplayer versus gmplayer? –  ImaginaryRobots Aug 25 '10 at 18:28
    
It is. The code under the first paragraph is from me testing it. –  Oli Aug 25 '10 at 20:51
1  
This is probably the cleanest solution :-) –  ℝaphink Aug 25 '10 at 22:01
    
Config files should always be the first place to look. Nice one :-) –  invert Aug 26 '10 at 12:29
    
Doing this to mplayer also fixes gmplayer or any of the other front ends to mplayer. Things like gmplayer call mplayer in the background, and just display the video in a frame provided by the skin application. –  Stuart Aug 30 '12 at 13:41
add comment

You could edit the /usr/share/applications/mplayer.desktop file to adujst the way the gmplayer command is called from the menu. Be sure to use dpkg-divert to make this change consistent locally:

$ sudo dpkg-divert /usr/share/applications/mplayer.desktop

This will tell dpkg to keep your modified version of the file in future package upgrades.

share|improve this answer
add comment

I am not totally sure how to complish this. other than writing a script that calls your executable with flags. But I know that in Eclipse that there is a eclipse.ini file in the same directory as the excutable that allows you to pass flags. Maybe looking into that you can write a similar file for gmplayer

I hope this helps. :)

share|improve this answer
add comment

The easiest way to do this, is probably the following:

  1. rename the executable in /usr/bin
  2. put in its place a script that will call the executable under the new name, that adds your argument.

    #!/bin/bash
    original-gmplayer -msglevel all=0 $@
    

Alternatively, you could put this script in the bin directory in your home, and make sure this bin directory is in your path (needs to be set system wide in order to work for applications that are not called from terminal)

share|improve this answer
    
Is there anything special that the script needs to do to pass along extra arguments? Say I replace gmplayer with my new proxy script, how can I pass, for example, --help or -vo onto the original executable? Or is this automatic? –  Oli Aug 25 '10 at 14:54
    
The $@ shell variable (or $*) contain all the arguments for the script. This means they are propagated to the call of gmplayer (obviously, gmplayer needs to be the new name for the original executable) –  txwikinger Aug 25 '10 at 14:56
    
the variable to pass on arguments is $@ the way you have your script written it allows the script as well to take arguments, and tack them on the gmplayer :) –  myusuf3 Aug 25 '10 at 15:05
    
Strange issue. When running it from the command line and passing the path to the video to my gmplayer executable, it worked fine but when double clicking a file it only gets the last part of the filename after the last space. In my case I was testing some Buffy I had ripped. A filename like: /media/ned/tv/Buffy/Buffy The Vampire Slayer 7x05 Selfless.avi was making gmplayer throw a file not found for Selfless.avi. Any ideas? –  Oli Aug 25 '10 at 15:28
1  
If you're going to replace anything in /usr/bin, use dpkg-divert to let dpkg know about it and make sure it doesn't get overridden when you upgrade the package. –  ℝaphink Aug 25 '10 at 21:16
show 5 more comments

As a different solution, use smplayer instead, which has the distinction of being actually maintained, and works great (which you cannot say of gmplayer).

share|improve this answer
    
smplayer is a different beast for a different type of person. I like gmplayer because it can fullscreen by default (remembers last setting), fullscreens on my second monitor (remembers last screen used), and its GUI is tiny enough that I can carry on doing things on my first monitor. –  Oli Aug 26 '10 at 15:46
add comment

You can create a symlink to your command. Create a command named mygmplayer, then verify where is your actual gmplayer command with whereis or which, then create a symlink to you command. Here an example

 $ echo '#!/bin/bash' > /home/user/mygmplayer
 $ echo "gmplayer -msglevel all=0" >> /home/user/mygmplayer
 $ chmod a+x mygmplayer
 $ which gmplayer
 /usr/bin/gmplayer
 $ sudo mv /usr/bin/gmplayer /usr/bin/gmplayer.old
 $ sudo ln -s /home/user/mygmplayer /usr/bin/gmplayer

Bye.

share|improve this answer
    
The last part needs to be done as root, surely? –  Oli Aug 25 '10 at 14:51
    
Yes, why not? I will edit the post –  lcipriani Aug 25 '10 at 15:44
    
This would be better done with a bash alias in ~/.bashrc. –  ℝaphink Aug 25 '10 at 21:12
    
Wait... did you actually test what you've posted? You want to replace /usr/bin/gmplayer with a symlink to a script that calls gmplayer... where will it find it? –  ℝaphink Aug 25 '10 at 21:14
1  
No you haven't ;-) You're still calling gmplayer instead of gmplayer.old in your script, and your symlink is of no use at all. It's generally not a good idea to advocate modifying anything in /usr/bin (unless you package it with Conflicts). –  ℝaphink Aug 26 '10 at 9:51
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.