The One with the Thoughts of Frans

VLC: Control Clone Window With Devilspie2

This is mostly the same post as that one in early 2011, but updated a little for Devilspie2.

My basic use case for combining VLC and Devilspie2 is to automatically output whatever video I’m playing on another monitor in fullscreen. If I were using Windows and an ATI card, I’d call it theater mode. nVidia cards also used to have a similar setting related to outputting pure overlay video on another screen, but it was removed from nVidia’s drivers around the time of the release of Windows Vista (and had been made buggy aspect-ratio wise a few years prior to that). Long story short, nVidia’s drivers have really degraded an awful lot since 2006 and I don’t like it one bit.

My answer to this problem is the VLC clone filter coupled with Devilspie2, which is a daemon that can automate all window manipulations, like pinning, moving around, resizing, moving to another workspace, et cetera. In order to do all this, you need to come up with matching rules for windows and put them in LUA scripts.

Since VLC is named VLC media player when it’s not playing anything, and clone video windows are also named VLC media player, I was initially having trouble coming up with a means of affecting clone windows without messing up my main window. Then I stumbled on the video-title setting in ~./config/vlc/vlcrc and changed it to VLC clone window. In the GUI this can be found if you show all preferences and go to video. Matching these clone windows in Devilspie2 is easy. The primary VLC window is still named VLC media player whereas the clone windows are now named VLC clone window.

# Video title (string)
video-title=VLC clone window

To understand how Devilspie2 works, reading the manual should get you started. You can normally start creating scripts in ~/.config/devilspie2/. Rather than repeating the simple examples given there, I will simply give you my finished VLC-clone-window script right now.

-- Make sure the clones counter is defined; do nothing if it is
-- This feature requires at least devilspie2 0.22
if (clones==nil) then clones=1; end

debug_print("application_name: " .. get_application_name());

-- VLC clone window
if (get_application_name()=="VLC clone window") then
	debug_print("clones: " .. clones);
	debug_print("Window Name: " .. get_window_name());
	debug_print("Application name: " .. get_application_name())
	if (clones==1) then
	-- Reset clones counter when it reaches two
	if (clones<2) then
	-- I'm not entirely sure what's going on here, but VLC seems to override this setting shortly after creating the clone window.
	os.execute("sleep .1");

-- VLC main (control) window
if (string.find(get_application_name(), "VLC media player")~=nil) then

I think that’s fairly self-explanatory. The clones variable counts the number of clone windows and resets itself when it reaches two (which is how many I use). You might wonder why I didn’t simply count to three, which is mostly for historical purposes. However, when I see VLC clone window on my taskbar that makes things a little more straightforward for myself. The hardest part is probably the fact that unlike in most languages I know, ~= is used instead of !=. Additionally, nil is used instead of null. If you have even a passing familiarity with a C-based language like ECMAscript, Java, or PHP, you should have no trouble with this very straightforward language.

1 Comment

  1. […] 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 […]

    April 17, 2013 @ 21:31Permalink
    A Poor Man’s Clone Window With Mplayer | The One with the Thoughts of Frans

RSS feed for comments on this post· TrackBack URI

Leave a Comment

You must be logged in to post a comment.