The One with the Thoughts of Frans

A Poor Man’s Clone Window With Mplayer

I haven’t been too happy with VLC 2.0’s changes to the clone window filter, nor with its allergies to removing window decorations from said windows. Since squeeze-backports broke my VLC a couple of days ago, here’s the closest alternative I could come up with: using MPlayer’s synchronized network playback feature on a single computer. However, since that requires running multiple instances of the program, it’s obviously a poor alternative to merely painting the same thing twice (as opposed to also reading from disk and decoding twice at the same time). On my computer it works fairly well up to 720p, and maybe on a faster computer it’ll even work with 1080p — but it can’t be good for the environment.

The surrounding fluff is my script for automatically enabling and disabling my intended output monitor.

#!/bin/bash
#mplayer-sync

# Check if the desired resolution is available and if not, add it. The check isn't really necessary for proper operation but it keeps down error output.
[[ "`nv-control-dpy --print-metamodes`" !=  *@1920x1200* ]] && nv-control-dpy --add-metamode "DFP-0: nvidia-auto-select @1280x1024 +0+0, CRT-1: nvidia-auto-select @1920x1200 +1280+0"
xrandr -r 51.0 -s 3200x1200

# -nosound is obvious, -udp-slave makes it sync with the master, -xineramascreen 1 is in my case where I want it to show up, and -fs stands for fullscreen
mplayer -nosound -udp-slave -xineramascreen 1 -fs "$@" &
mplayer -udp-master "$@"

# Give everything time to exit before checking
sleep 1

# Check if there's still an instance of VLC running.
# $$ is the process's own PID; testing the exit code of pgrep vlc for success wouldn't work 'cause this script itself would still cause that to test positive. Incidentally, see how to check for exit codes at http://linuxcommando.blogspot.com/2008/03/how-to-check-exit-status-code.html (Yes, this comment is all based on me testing something and wondering for a minute or so why my script wasn't working correctly.)
# To check that you can try
#somecommand  argument1 argument2
#RETVAL=$?
#[ $RETVAL -eq 0 ] && echo Success
#[ $RETVAL -ne 0 ] && echo Failure
[ "`pgrep mplayer`" == $$ ] && xrandr -r 50.0 -s 1280x1024

1 Comment

  1. As an aside, they fixed VLC on squeeze-backports.

    April 19, 2013 @ 11:53Permalink
    Frans

RSS feed for comments on this post· TrackBack URI

Leave a Comment

You must be logged in to post a comment.