4

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.

moberley
  • 962
  • 9
  • 15
Oli
  • 289,791
  • 117
  • 680
  • 835

6 Answers6

8

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
Oli
  • 289,791
  • 117
  • 680
  • 835
Stuart
  • 1,176
  • 1
  • 8
  • 13
3

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.

raphink
  • 1,070
  • 1
  • 8
  • 15
1

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. :)

myusuf3
  • 33,569
  • 41
  • 88
  • 103
0

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)

Oli
  • 289,791
  • 117
  • 680
  • 835
txwikinger
  • 27,944
  • 10
  • 78
  • 101
  • 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
  • You have to insert the backslashes: `/media/ned/tv/Buffy/Buffy\ The\ Vampire\ Slayer\ 7x05\ Selfless.avi` – lcipriani Aug 25 '10 at 15:59
  • that is a problem with `$@` use this instead `$1` `$2` for your variables it doesn't handle spaces well. @icipriani he can't delimit them since they are being passed as a file name. – myusuf3 Aug 25 '10 at 16:30
  • 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. – raphink Aug 25 '10 at 21:16
  • If an update replaces the script, thinking it is the original executable, then what? – invert Aug 26 '10 at 12:14
  • @Oli: the script is missing some quotes: `$@` should be `"$@"`. That's why it failed with an argument containing spaces. (@garbagecollector: your suggested use of `$1`, `$2`... is useless. The problem is the lack of quotes.) – Gilles 'SO- stop being evil' Aug 26 '10 at 23:35
  • @KeyboardMonkey: either follow Raphink's advice and use `dpkg-divert` to tell the packaging system that you now “own” `/usr/bin/gmplayer`, or better, put your script in `/usr/local/bin`. – Gilles 'SO- stop being evil' Aug 26 '10 at 23:37
0

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

loevborg
  • 7,152
  • 1
  • 27
  • 24
  • `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
-2

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.

lcipriani
  • 417
  • 3
  • 6
  • 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. – raphink 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? – raphink 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). – raphink Aug 26 '10 at 09:51
  • Rahink is right, rather avoid messing around in /usr/bin. – invert Aug 26 '10 at 12:27
  • Yes, he is right about /usr/bin, but the ln command works. He has not tested my code, it works. The ln man says: `ln [OPTION]... [-T] TARGET LINK_NAME` It is clear that if the target link does not exists (I have just modified the name of gmplayer to gmplayer.old), then the ln command does the right thing. Thank you for suggestion. – lcipriani Aug 27 '10 at 07:26