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())
	
	pin_window();
	
	if (clones==1) then
		set_window_position(1280,0);
		maximize();
		undecorate_window();
	end
	
	-- Reset clones counter when it reaches two
	if (clones<2) then
		clones=clones+1;
	else
		clones=1;
	end
	
	-- 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");
	make_always_on_top();
end

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

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.

Comments (1)

A Clove of Day

The Middle-Eastern man opposite him was characterized by a distinct garlic smell. Why did people make such a fuss about the smell of garlic by making funny faces, especially when there were disgusting smokers stinking up the air, with what seemed like years’ worth of cigarette fumes stuck in their clothes? Yet it would be strange to assume smokers washed their clothes any less than other people. The tram was driven by a madman — no, a madwoman. Better yet, by someone trying desperately to keep the tram on schedule. The big truck trying to turn in a tight corner didn’t help, but the driver was determined to make it to the next stop on time. She wasn’t going to make these poor people miss their connection. Earlier that week she’d been reprimanded because her GPS-based performance review was below average. You need to drive faster. I’ll try, she said. Choo, choo!

He was just about the only white person in the tram. Was it racist to notice? Of course it’s not, not unless you think the other people don’t belong. Fuck, I’m an immigrant myself. Not that he was what the haters thought of when they used a word like immigrant — they didn’t think of Caucasians who spoke their native language. Spoke it better than they did.

As the crowds mysteriously dissipated inside the central station, he sat down to study a bit before the train arrived. A couple of pages till he had to move would be nice, but just about everyone seemed to have a cold. Sniffing, sneezing, wheezing, coughing, blowing noses — the other travelers were trying their best to produce an orchestrated cacophony. Their timing was impeccably unrhythmic. A whiff of garlic sauce interrupted.

Oh yes, it was lunch time.

Comments off

New E-ANS Location

I couldn’t find the E-ANS website (a Dutch grammar), but apparently it moved to a new location without any kind of redirect (via).

Comments

Musings on Window Switching

While I do like Unity’s Super + # idea, there are some rather serious flaws with the concept: the first and most obvious flaw is that you have to use Super + # first, after which you’ll have to utilize Alt + ` to actually select the window you want. The second major flaw, which may not be obvious while you’re trying Unity on a LiveCD for the fist time, is that # is all it is. The logical continuation of the concept after reaching 10 windows or applications would be [a-z]. I assume the reason they didn’t implement that is because it would interfere with various other Super + something keyboard bindings.

My vision of the correct way to implement window switching would look something like this (image manipulated based on a superswitcher screenshot):

If you press Alt + Tab and keep Alt pressed, a window much like superswitcher pops up. Perhaps most importantly this means a list of windows, consisting of an icon followed by the title of the window. This means a rejection of near-useless giant icons and thumbnails without any means of differentiating between various windows of one single application. All the windows in this list should be numbered: first [0-9], followed by [a-z], and I suppose in the somewhat less likely event that more is required, [A-Z]. Hence pressing Alt + [0-9a-z] or Alt + Shift + [A-Z] immediately takes you to a certain window. Other than that, superswitcher’s keyboard shortcuts could be retained as they’re quite intuitive: Alt + F1, F2, etc. takes you to a different workspace, Alt + arrow keys allows you to select a window, Alt + Esc closes a selected window, you can click on windows to activate them, etc. Activate the switching interface with Alt + Tab first, hold Alt, and then do your thing.

superswitcher’s search functionality is something I’d probably never even think about if this functionality were present, but it could be retained by pressing Alt + : or some such to activate it.

I would retain the Caps-Lock-override functionality, for Caps Lock may well be the most useless key on anything that isn’t a mechanical typewriter, but I’d make it into a toggle. A Switch Lock, if you will. But that’s probably something that should be configurable.

The most straightforward means of obtaining this functionality would probably be a few modifications and additions to the source of superswitcher. Unfortunately my knowledge of C++ is insufficient.

I did manage to hack in regular Alt + Tab behavior, with major emphasis on hack, through XBindKey and XGrabKeyboard. It works in Unity, but Metacity just laughs at me even if I disable its own stranglehold on Alt + Tab. I guess it also has a stranglehold on Alt or the keyboard as a whole or something.

Comments

Beyond the Walls

There's a fourth wall that needs to be broken down.
Governments and official voices point out forever that good fences make
good neighbours, and tighten the border controls in an effort to make us
happy where we are.

But something there is that does not love a wall, and it's called humanity.

From Vier Mauern by Neil Gaiman and Dave McKean (1990).

Comments

The Days of Terror

Here’s a silly story I wrote about a decade ago.


When I was born, I was immediately aware of everything around me. I was aware of my father, who also was my mother. Or maybe something entirely different. In a way, I was my father. But that doesn’t matter now. It’s not important for the story I’ll tell you. A story which is of great importance, for I am the last still alive born prior to the End of the Suffering. Therefore I must relate my experiences from the first days of my youth. This knowledge should not be lost.

Like I said, I was immediately aware of my surroundings. Unlike the larger creatures, formerly the masters of the earth, we are as you know one big, conscious growing process. When we are cut off from our base, we stay alive long enough to pass our acquired knowledge to our main body. It’s partially because of this, that I can account of these events so well.

When I was only a few days old, I had my first experience with what is now only vaguely remembered as the Days of Terror. Compared to our present freedom, the Days of Terror lasted longer than any of us can remember. Nevertheless, it was gruesome.

I wasn’t prepared for it. I was just standing there happily, gazing at the sun, when suddenly I heard screams in the distance. First I couldn’t hear what the screams said, but the screams seemed to come closer and closer. After a short while, although it seemed to last for hours, I could finally hear what they were screaming. No! Not again! Spare me! I will stay small!

As the young lad I was, I didn’t understand it at all until suddenly it hit me. A sharp piece of metal hit my body and sliced me in two. Part of me was lifted by an air stream generated by the sharp piece of metal. It was then that I, or rather a long-dead piece of me, first met Him. We must not let this happen to us without doing anything! is what He was shouting at anybody who would could hear. We must fight back!

It was an unwilling crowd. All the pieces of the older ones retorted that it had always been like this. They were not prepared to do anything. But I was, having experienced this terror for the first time and being completely shocked that something like this could happen. So I replied: What do you propose, what can we do against this terror?!

We must attempt not to grow to the sun, but stick to the ground! He replied. So this is what we did. We stuck to the ground. The older ones didn’t do so, however. And so, a few days later, when the Terror came again, they had grown all the way up again. Suddenly scared, they grabbed the few of us lying down on the ground, pulling us with them. Thus it happened again, struck by the Terror for the second time. But now those surrounding us had seen that we were initially not harmed. That day we gained many new followers.

A few days later, we could already celebrate our first little victory. None of those around Him, me and the few other original followers were harmed. This was a vital breakthrough, and the news spread quickly among our brothersisters. I considered this to be the end of it. I thought we could all live like this, happily ever after, until the end of days. But it wasn’t like that for Him. He was far from satisfied. Only the first phase of His big plan to change the world forever had succeeded.

None of us knew what He was up to at first. He was busy with something, but none of us knew what it was. It was such a novel idea that we didn’t even grasp the idea when he first succeeded at what he had been trying for so long. To make a long story short, he had somehow managed unrestricted movement. This might all sound very strange to you today, but at the time, none of us had ever done it. Millions of years had passed and yet He was not only the first to think of it, but also the first to actually achieve it.

With His new abilities, He went to visit all of us. While those close to him, including me, were trying to master this new technique, He walked further and further, visiting those who had but barely grasped the idea of lying down. Walking was an exaggerated rumor to their minds, until they saw it in real life. As I was still relatively young, I did not do much with this new technique, but the older among us, who knew they were going to die quite soon, set out for exploration. They walked up to our great brethren at whose feet many of us still grow, and tried to initialize communication with them — another novelty. After a while they even succeeded, but they were not enthused by the concept of walking.

Many of those exploring never returned. Newer expeditions found out that it was due to lack of food, so newer expeditions decided to be in the ground half of the day to prevent starvation. Because most of us preferred to wander by day, this became known as night rest or sleep in common parlance.

He was happy with our achievements for a while, but as soon as most of us were able to move as well as He could, He wanted more. Instead of avoiding the Terror, he argued, we should attack the Terror. It might take some victims, but it would be worth it in the end, for we would be rid of the Terror. We felt like we could do everything after having mastered movement, so almost all of us agreed with whatever He could come up with.

So the days went by and inevitably the Terror came again. As it was not the metal, but the two things behind it which were important, as He argued, we should shrink away from the metal and then attack the two things behind it. He would give the sign.

Lying down, we waited for the metal to pass. Then, on his signal, we all extended over one of the two things. I don’t remember what we expected, but something much larger was attached to the thing and it fell down, crushing many of us.

The others, who had been waiting at the side, now jumped on the most important part of the Terror. The destructive metal didn’t seem to be doing anything anymore now that we managed to take down the controlling Terror behind it. We jumped all over the Terror, tying it. The Terror tried to get away and a long struggle ensued. At last it stopped moving.

Those who hadn’t actually helped getting the Terror down now went to look. The thing, which had given off warmth before, seemed to be cooling down. But then, not too long after having killed this one, another Terror approached. It was moving much faster than we were used to, so first it crushed many of us while running towards the lifeless Terror on the ground. But then we got hold of it. Tying it down to the ground, we repeated what we had done before. Again we succeeded.

As the months passed, we spent our time taking out an ever increasing number Terrors. Also, thanks to our movement technique, we found out that both we and the Terrors were with many more than we ever had expected. More importantly still, we were with many, many more. Our army kept on steadily growing and growing as we continued our struggle, The Terrors applied many different ways of fighting us. Billions upon billions were murdered in blistering flames. Later, these weeks became known as The Days of Terror, as the Terrors seemed to have reached a turning point. However, we found out that drinking our weight in water, while making us only barely able to move, also protected against the flames. From that moment, the war was all but won. The Terrors were cowardly running retreating. They fled to places were we couldn’t follow. As you know, they are still there. But they dare not harm us any more.

Finally having gained our freedom, we also thought He was appeased. But He was not. He wanted us to think of new techniques to better our lives. But it was then, that he suddenly passed away long before His time. A sudden frost struck us, and like many He was frozen. Still, the casualties were few compared to the battles we fought against the Terrors.

Our first independent new idea was to protect ourselves from things like frost. If we could battle the Terrors, why not winter? The Terrors left their dwellings behind, and we occupied them. Our scientists, as those with an aptitude for coming up with and testing hypotheses are called now, researched these dwelling. They found a lot of interesting stuff, but not all has yet been uncovered.

Recently the purpose of the objects made out of the dead bodies of our great brethren was discovered. These contain knowledge. The very kind of knowledge you are looking at right now. Yes, He changed the shape of the world forever. As the last of those who were there, it is my time to go now. I can already feel life flowing out of me. I’m no longer able to drink well any more.

I hope this message will not be lost over time. Do not forget the past. Do not become new Terrors yourself. Good luck living in the most exciting of times.

Comments

SSD Optimizations

As I wrote yesterday, I migrated my Linux install from an HDD to an SSD. That runs great by default, but you should add the discard argument to the relevant entries in /etc/fstab to enable TRIM support. Long-time SSD performance should remain great thanks to that simple action, which in my case looks like this:

# /dev/sda1
UUID=b8024bbf-9d29-417d-b6eb-ef87d0d586ec /               ext4    errors=remount-ro,discard 0       1
# /dev/sda2
UUID=30efde45-b883-464d-966c-605e091078b9 /home           ext4    defaults,user_xattr,discard        0       2

Some also recommend to set noatime to prolong your drive’s life, but since relatime is the default these days that doesn’t seem necessary to me. However, what you should probably do if you’ve got a sufficient amount of RAM, is to mount /tmp in it.

tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0

You can do the same thing with your logs, but I’m not too sure whether I want to do that myself, even if it would cut down on writes.

Comments

Copy Your Linux Install Without Using DD

I know, everyone’s all over dd and depending on your needs it can be a great tool. However, for a variety of reasons it may not always be what you need. In my case I was migrating my OS to an SSD, and I wanted to upgrade from ext3 to ext4. In spirit this post is no different than the 2009 article on this subject in Linux Journal, but being from 2009 is exactly why it didn’t quite work for me today.

To start, get a live CD and boot into it. I prefer Ubuntu for things like this. It has Gparted. Now follow the steps outlined below.

I don’t think a LiveCD is strictly speaking required, but it’s certainly the safest route. As an aside, using an external USB hard or flash drive typically gives you significantly better performance than a DVD drive.

Copying

  • Mount both your source and destination partitions.
  • Run this command from a terminal:

    sudo cp -afv /path/to/source/* /path/to/destination

    Don’t forget the asterisk after the source path.

[…]

Configuration

  • Mount your destination drive (or partition).
  • Run the command “gksu gedit” (or use nano or vi). [I prefer SciTE myself.]
  • Edit the file /etc/fstab. Change the UUID or device entry with
    the mount point / (the root partition) to your new drive.
    You can find your new drive’s (or partition’s) UUID with this
    command:

      $ ls -l /dev/disk/by-uuid/

That’d be the end of what’s still usable. Here’s what you need to know to set up GRUB 2 on the new disk.

sudo mount /dev/sdXY /mnt #most likely something like /dev/sda1 or /dev/sdb1
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
chroot /mnt

Here we mount the relevant partition, chroot into it, and give it access to what Grub will need to set up. chroot allows you to effectively run multiple systems without needing to reboot. All that should be left now is to install Grub:

grub-install /dev/sdXY
update-grub

Do you love the consistency there as much as I do? Anyway, notice that you need to run update-grub manually since grub-install doesn’t do it for you. It sure tripped me up.

In case you’re migrating to an SSD like I did, there are some other adjustments to make, which I’ll write about in more detail soon.

Comments

I Joined the Dark Side

Back in 2010 I was really looking forward to the upcoming MeeGo phones by Nokia, but alas, it was not to be. My five-year-old phone started dropping its connection now and then for no apparent reason, so it was time to upgrade. Unfortunately all the phones out there seemed to be either mini-tablets or otherwise not living up to my requirements, but a few weeks after I’d stopped looking I almost accidentally came across the Sony Ericsson xPeria ray. It combined two features very important to me: it is not a small tablet and it has a nice resolution, resulting in nigh 300 PPI. Can I get the latter on desktop monitors please, instead of that paltry 1080p HD that seems to be popular right now?

I intend to document some of the apps I’ve installed and why, and perhaps also why I quickly uninstalled some others. To that extent it’s more of a public note to self, but who knows — it might just help to someone else.

Sense Analog Clock Widget
Because none of the other clock widgets were big enough. Call me old-fashioned, but I like a big clock to be the first thing I see. The weather, system info and configurable click actions are a nice touch.
K-9 Mail
The default e-mail client was alright, but not really any better than what my old SE s500i gave me over half a decade ago. Besides, it’s mostly just the default client with some bells and whistles.
K9 Mail Unread Count Icon
Unlike the default e-mail client, K-9 Mail doesn’t display the number of unread messages in its icon. This widget takes care of that.
Keyboard from Android 2.3
I like the default Android 2.3 keyboard better than the one Sony Ericsson included. You can choose your preferred keyboard by long-pressing on a text-input field. Among the advantages are that it’s easier to type symbols and you can change languages by a simple swipe on the space bar. Besides, it has a speech recognition button built-in so you don’t necessarily have to type on the screen.
AndFTP
I tried a few FTP programs. Most were lacking in the SFTP department. However, I think it may not ask before it overwrites files.
Dropbox
Heck, it’s useful. Besides, they give you 500MB of extra free storage.
ArchiDroid
I need to extract files sometimes. Duh.
OI File Manager and Open Manager
I haven’t decided which one I like better, but it’s preposterous that something like this wasn’t included by default. Did I mention my feature phone came with a basic file manager?
Barcode Scanner
Very straightforward. It scans those funky QR code blocks without any fluff.
QR Bookmarklet
This one actually isn’t for my phone, but for my regular browser. I saved it among my bookmarklets and gave it the nickname “qr”. Now if I want to open any page on my phone, I can just type “qr” and use Barcode Scanner.
Opera Mobile and Opera Mini
Are any other browsers even in the same league? Mobile for Wi-Fi, Turbo for when a real browser might be required on the go, and Mini for true data saving. Also consider Firefox. The default Webkit browser is bearable, but basically awful. Note that while Opera Mobile supports options like site preferences, adding them is a bit of a pain due to the lack of a simple interface.
Battery Widget
I like a big battery indicator — and the little one it adds to the notification bar has an actual number so you know what’s going on.
Screebl Beta
The best argument for those motion sensors yet. It disables or holds back the screen timeout while the phone is in your hand and can speed it up when you lay it down.
Timeriffic
Again, it seems like this should be included by default. Set your phone up to stfu at night and whenever else you don’t want it to ring. You can also change some other settings if you want, but for me it makes more sense to turn e.g. Wi-Fi on manually.
OpenOffice Document Reader
LibreOffice is my preferred office application after HTML + CSS rendered to PDF with Prince. I may want to look up something in one of my documents on the go.
wifi AutoSyncAutoToggle widget
I don’t really want my phone wasting CPU or data on syncing unless I’m on WLAN. This takes care of that. Don’t forget to tell your applications to obey this setting. Other applications, most notably Google Play Store, don’t necessarily live by this setting, but sport options like “update or sync over Wi-Fi only.”
SD Tools
I don’t know if I’d recommend installing it per se, but benchmarking the speed might interesting for comparison.
Maps With Me
It’s a lot like Google Maps, except it’s based on OpenStreetMaps and offline. There are more OSM apps out there, but most I’ve tried seem to be less fluid, uglier, or default to turning the GPS on. I’m just looking at having a decent 2D map just in case — I’ve got an actual GPS with a bigger screen (albeit sadly with a much lower PPI value) for driving. Surprisingly, although I also gave a few commercial applications a try, their 2D maps didn’t seem nearly as usable as the Google Maps or Maps With Me varieties. The commercial apps have loads of POIs though, which might sometimes be useful.

Aard Dictionary
In a similar vein, I’ve now got The Collaborative International Dictionary of English and the entirety of Wikipedia on my phone. It’s not only useful for when you don’t want to use data: it’s actually really, really fast. There are more dictionaries available, or you can make your own. The only downside I can think of is that SVGs (which presumably shouldn’t take too much extra space) are missing from the files.

Android is certainly usable, but ultimately it’s too Apple-ish for my tastes. It’s also a bit annoying that by default everything’s set up to use data all the time. I understand that connectivity is a big factor of the device, but it’s no wonder people complain about low battery life if their phones are synchronizing all kinds of things every few minutes. If I’m on the go I can live with checking for new e-mail manually to conserve both data usage and battery life. Ultimately, while I’m happy with my new phone, I hope real GNU/Linux will be available before I have to buy a new one again.

Comments

Using WordPress Excerpts in Meta Description

For a long time I’ve been aware of the fact that few, if any, WordPress themes seemed to do anything with the META element’s description feature. I never bothered to look into a solution, especially since I never used to add excerpts to my posts half a decade ago. However, I’ve bothered to do so ever since I started notifying people about updates on Twitter. It already makes the search results much more readable if you’re looking for something in the archives of this site, and I figured I should do the same for search engines.

Some uneventful searching later I found what I was looking for, but it definitely wasn’t right for me: I’ve got a huge volume of posts without any excerpts, so printing empty descriptions no matter what would be silly at best, and besides there are more descriptions out there than merely those of posts. After all, categories and even my site itself have a description as well. The comment by Matthew Slyman was much more to my liking, which I then customized as follows:

<?php
$desc;
if ( is_single() ) {
	$desc = get_the_excerpt();
}
elseif ( is_page() ) {
	$desc = get_the_excerpt();
}
elseif ( is_category() ) {
	$desc = category_description();
}
elseif ( is_home() ) {
	$desc = get_bloginfo('description');
}
$desc = trim(strip_tags($desc));
if (!empty($desc)) {
	echo '<meta name="description" content="';
	echo $desc;
	echo '"/>';
}
?>

Add the whole thing anywhere in your HEAD element in header.php. If excerpts seem to be missing from pages, there’s a simple solution. If you want to reuse the code above for some reason, wrap some sort of function around it and stick it in functions.php. Enjoy.

Comments

« Newer EntriesOlder Entries »