Archive for March, 2012
As I wrote last year, I wish to “automatically output whatever video I’m playing in fullscreen on another monitor.” Because the other monitor isn’t next to my main monitor, most of the time the output doesn’t have any practical purposes. That isn’t the biggest problem, although you might want to consider Mouse Jail. However, I recently changed from Nouveau, the open-source nVidia drivers, to nvidia-glx, the proprietary nVidia drivers that offer all the latest and greatest OpenGL acceleration: I wanted to play Achron.
After extracting the Achron archive, it turned out that the game wanted to spread across the entire virtual space available, i.e., across both of my monitors. Disabling one monitor is easy enough, but it would have to be automated. Besides, figuring out how to automate this would be a fun exercise in itself.
First of all, there were some issues with xorg.conf. nvidia-settings can generate one, but it’s not the greatest and requires some manual modification, if only to make sure your own mouse remaps and what not aren’t left behind. What we’re interested in is the section where it talks about metamodes. I thought I’d need two of them to enable easy switching: one with the second monitor enabled and one where it was disabled. Since I only actually use the second monitor for VLC video output, it should be disabled by default and enabled only for VLC:
Option "metamodes" "DFP: nvidia-auto-select +0+0, CRT: NULL; DFP: nvidia-auto-select +0+0, CRT: nvidia-auto-select +1280+0". Alas, if only it were this simple. As it turns out, now the graphics driver creates a gigantic virtual display space in order to accommodate the largest resolution metamode, allowing you to pan around in it. New plan: we disable the second monitor on boot and dynamically add a metamode when starting VLC. The line in xorg.conf now looks only like this:
Option "metamodes" "DFP: nvidia-auto-select +0+0, CRT: NULL".
So, how to add metamodes on the fly? Well, the nvidia-glx driver comes with this nice little utility called nv-control-dpy. Based on that I wrote the following shell script to start VLC:
#!/bin/bash # 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 # See http://www.andymillar.co.uk/blog/2010/03/17/limiting-vlc-memory-usage/ source /etc/profile ulimit -v 1048576 /usr/bin/vlc $@ # 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 vlc`" == $$ ] && xrandr -r 50.0 -s 1280x1024
The nVidia driver plays a little trick on X11 by pretending the different metamodes have different refresh rates. In some future update this should no longer be necessary, but for now that’s how you can easily switch between them with xrandr. The script is named vlc and added to my PATH in such a manner that it overrides the default link to the VLC binary. I think that should be enough information to adjust this to your own personal needs.
Half a year ago’s post, about why we decided to buy a washing machine two years ago, was actually written back in September or October of 2009. I didn’t post it at the time because it made me aware I had no table styling. I then proceeded to make a testcase for table styling, which I presumably finished before October 2009 was over.
Sadly for the post, however, I then forgot about it till last year, when I found my table styles testcase during my switch from NTFS to ext4. This had the side-effect that I started incorporating various stylesheet upgrades I’d written over the past two or three years, giving you a different default width and fancy schmancy transition effects today — or actually already back in May 2011 because that’s how long it took me to actually publish this. I really do need to stop putting things in drafts for potential revision without ever picking them up again.