The One with the Thoughts of Frans

Archive for April, 2011

Kiwis These Days

Wil Wheaton is always posting conversations he’s had with his wife, so why shouldn’t I?


“You want kiwi?” I asked.

“There is cold?” Mel replied. She doesn’t like fruit that hasn’t been refrigerated, which I take into account unless I happen to forget about it.

“Yes! There’s alway cold kiwi. It’s like a disease. They just jump in the fridge these days. I was walking through the fridge this afternoon—”

“You were walking through the fridge eh?”

“BY!!! By the fridge! And this kiwi suddenly jumped up against me, and I was like, ‘dude wtf are you doing.’ The kiwi was really rude. It said: ‘fuck off, you ass, you’re blocking the road to the fridge.’ So I said ‘chill, kiwi.’ It replied, ‘yeah, that’s what I want to do, Einstein, but you’re keeping me from it.’ I wasn’t going to put up with that, so I said, ‘first apologize for your rudeness or I’ll just let you rot.’ Then it just kind of rolled over like it were one big, giant eye, shrugged — honestly, it did that! — and said, ‘sorry that I bumped into you but I really need to get into the fridge now.’ I opened up the fridge and said ‘alright, but no more shenanigans or I’ll drag you out of there if it’s the last thing I do.’ It jumped right in and let out a big sigh: ‘aaaaaaaaaaaaaaaaaaahhh.’ Then it pulled the fridge closed while muttering something about privacy. So yeah, that’s how kiwis are these days. No respect.”

She didn’t reply verbally, but she pulled… the face.

Comments

Lossless Rotation with jhead and jpegtrans

I like my pictures rotated in such a way that I don’t have to depend on application support for them to be displayed correctly. jpegtran (pre-installed on most distros) is a wonderful application with many features, including lossless rotation, but it’s too laborious for my purposes. That’s where jhead comes in.

You can simply go into a directory, run a command like the following, and everything will be done automatically for you.

jhead -autorot *.JPG

Of course I wouldn’t run it if you don’t have a backup available. I always keep the pictures around on my camera until I’ve confirmed that all processing was successful and then I still don’t delete them until the adjusted files were also copied to my external HDD in my semi-regular backup regime.

Another utility that can perform the same task is exiftran, but despite being more or less dedicated to this very purpose it’s not even easier to use: I’d expect exiftran *.JPG to default to the equivalent of the jhead -autorot *.JPG command I posted above, but instead you have to use exiftran -ai *.JPG. All other things being equal for my purposes, I decided to go with jhead because it has many more features — although last year I decided that exiv2 is superior to jhead in ease of use for most of those features.

If you’re just looking for the occasional lossless rotation, you could also try the Geeqie image viewer and manager. It integrates calls to exiftran, but beware that you explicitly have to choose the lossless option, as there are also lossy rotate options.

Comments

Dolby Digital 5.1 Over S/PDIF With PulseAudio

This post is from 2011 and relates to Debian Squeeze. I put up a newer post in 2013 when Debian Wheezy was released.


This post describes how I got Dolby Digital 5.1 output working over S/PDIF on my onboard Realtek chip with other audio sources mixed in. Previously I was only able to achieve either 5.1 output by sending the data stream straight to my receiver, or 2.0 output with everything mixed in. The experiences detailed in this post originate in Debian Squeeze, but if what I wrote is specific to anything, it should be my hardware — not Debian and its derivatives. Before you read on, you might want to check out this forum post instead, which describes a method that didn’t work out for me.

PulseAudio 0.9.22 is required; it won’t work on older versions of PulseAudio. Debian Squeeze comes with ALSA 1.0.23; presumably that’s much less significant. On Debian getting this most recent PulseAudio can be done through the experimental repository.

If you’re on Debian ALSA is already setup, including the required libasound2-plugins, but to get the most recent version of PulseAudio you’ll want to add deb http://ftp.debian.org/debian experimental main to /etc/apt/sources.list, and then type apt-get update && apt-get -t experimental install pulseaudio in a superuser terminal (see the Debian Wiki for more information on the experimental repository). On many other distributions PulseAudio is already setup by default, but just like on Debian Squeeze that’s typically still PulseAudio 0.9.21 at present.

On Ubuntu you’d have to recompile libasound2-plugins yourself because it doesn’t include the a52 ALSA plugin by default. The link in the opening paragraph should describe that process sufficiently.

In the System Log Viewer you can keep an eye on syslog for (error) messages from ALSA as well as PulseAudio.

What follows is my /etc/asound.conf, heavily condensed from Johannes Bauer’s Dolby Digital with Linux and ALSA guide. It works quite nicely (with some minor adjustments), but it will only allow one application to utilize audio at a time. One could utilize PulseAudio for stereo while suspending it (with pasuspender) when you want to play a movie or some such with 5.1 audio, but I’d rather mix everything together in PulseAudio so I don’t have to think about it after the initial setup, just like in Windows.

pcm.a52 {
        @args [CARD]
        @args.CARD {
                type string
        }
        type rate
        slave {
                pcm {   
                        type a52
                        card $CARD
                }
                rate 48000 #required somehow, otherwise nothing happens in PulseAudio
        }
}
pcm.pulse {
        type pulse
}
ctl.pulse {
        type pulse
}
pcm.!default {
        type pulse
}
ctl.!default {
        type pulse
}

Now that you’ve got the ALSA configuration in order it’s time to make some slight adjustments to /etc/pulse/default.pa or PA won’t detect the possibility for Digital Surround 5.1. According to various sources they had some kind of Digital Surround show up automatically, but I had to explicitly tell PulseAudio about its existence. Adjusted from a comment on Ubuntu bug 348353 (which incidentally is why you need PulseAudio 0.9.22).

load-module module-alsa-sink device=a52 rate=48000 channels=6 tsched=0 sink_properties=device.description=SPDIF sink_name=SPDIF channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe

I initially added this line without the channel_map, but then PulseAudio thought I had something like front-left,front-left-of-center,front-center,front-right-of-center,front-right,lfe, which would be a strange setup indeed.

I’m not quite sure whether the channel map might be more appropriate in /etc/pulse/daemon.conf, where I uncommented default-sample-rate = 48000. I also added the appropriate settings for default-sample-channels = 6 and changed enable-lfe-remixing to yes.

pavucontrol is instrumental in quickly seeing what’s going on and for application-specific volume settings. Not utilizing it would be a disservice for yourself if you’ve chosen to use PulseAudio.

Now that we’ve got all the configuration set up you could reboot the computer, but one of the great things about Linux is that you rarely have to do that other than to load a different kernel.

As user: pulseaudio --kill
As superuser/sudo: /etc/init.d/alsa-utils restart
(As user: pulseaudio -D, but that shouldn’t be necessary)

I utilized the surround test ac3 file from Lynne Music (straight to directory). I played it with mplayer -channels 6 to make sure everything was working correctly and to adjust the channel map. At this point everything was finally working fine for me, but most applications still were not cooperating because they defaulted to ALSA. Again, in Ubuntu this shouldn’t be an issue.

Various adjustments are still required in most applications. For instance, in Totem you have to explicitly set audio output to 5.1 in Edit > Preferences > Audio.
For MPlayer put channels=6 in ~/.mplayer/config (note that if you can’t get PulseAudio to work you could add the equivalents of mplayer -ao alsa:device=spdif -srate 48000 -ac hwac3 file.avi if you so desire).
VLC works fine if Dolby Surround is set to Auto in Tools > Preferences > Audio.

To get the 6 channel output to work in applications that use SDL (Gnash, quite a few games) you’ll need libsdl1.2debian-pulseaudio. This will replace libsdl1.2debian-alsa. Of course this won’t be necessary if your distro is set up with PA by default.

On a separate note, I set PulseAudio up so it can play audio from all kinds of sources (most notably my laptop).

Comments (7)

Mouse Jail

One of the applications I like to use on Windows is Mousenitor, which enables advanced mouse control for users with more than one monitor. It was written by a friend. I haven’t yet figured out the best way to trap my mouse on one monitor in Linux, but a little application named Jail offers a rudimentary implementation. It was originally written by Sebastien Marion, but I picked up a slightly modified version from the Ubuntu forums.

If you want to compile it yourself you need to grab apt-get install build-essential libx11-dev libxtst-dev in Debian (and presumably the same for derivatives like Ubuntu). For good order I also uploaded the source, including my compiled x64 binary, to my own server lest the original source code might be deleted. Download jail.tar.xz if you want to test it. Edit .JailSwitch.sh to correspond to your system.

The Gentoo Wiki possibly describes more elegant, but more involved methods to obtain a similar effect. I’ll report back if I can get one of those methods to work successfully, and if they do indeed work more elegantly.

Comments

SVN

Just a quick reminder to myself: SVN is short for subversion, so to install it you need apt-get install subversion.

Comments

VLC: Control Clone Window With Devilspie

My basic use case: automatically output whatever video I’m playing in fullscreen on another monitor. 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 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 Devilspie, but sadly it’s not quite as straightforward as I’d like. Devilspie is a wonderful daemon that can automatically do everything you can do to windows like pinning, moving around, resizing, moving to another workspace, et cetera. In order to do this you need to come up with matching rules for windows, and sadly it’s a tad more limited in that respect than I’d like. Anyway, you’ll want to grab gDevilspie with apt-get gdevilspie (or sudo apt-get gdevilspie, of course), which should automatically pull in devilspie as a dependency.

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 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 (I couldn’t find this setting in the GUI). Now matching it in Devilspie was a piece of cake. 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

What follows is something I couldn’t have written as quickly without gDevilspie, but I had to switch some commands around (like putting geometry first instead of last) to obtain the precise situation I wanted, for otherwise VLC returns the window to the original monitor when exiting fullscreen.

( if
	( begin
		( is ( window_name ) "VLC Clone Window" )
	)
	( begin
		( geometry "+1280+0" )
		( maximize )
		( undecorate )
		( above )
		( pin )
	)
)

Now that I got the gist of the syntax I decided to also pin the smaller window on top and extended the configuration file. The official man page is rather lacking, so I recommend foosel’s unofficial documentation instead (via ruario). You can find the generated files, or make your own, in ~/.devilspie/.

( if
	( contains (application_name) "VLC")
	( begin
		(if
			( is ( window_name ) "VLC Clone Window" )
			( begin
				( geometry "+1280+0" )
				( maximize )
				( undecorate )
				( above )
				( pin )
			)
		)
		(if
			( contains ( window_name ) "VLC media player" )
			( begin
				( above )
				( pin )
			)
		)
	)
)

I think that’s fairly self-explanatory. My hope is that matching the application name to VLC will make sure that any other application with a window_name that contains VLC media player for some reason (or VLC Clone Window) will be unaffected.

If you didn’t find this quite as enlightening as you’d hoped, once you’re in gDevilspie everything’s pretty much explained in there, and otherwise the documentation I linked to should be of assistance. The only thing above I’d consider somewhat puzzling at a glance is the offset. The resolution of my monitor is 1280×1024, so the x offset of +1280 makes sure that everything’s on the correct monitor before maximizing. You can also set a window size, so then it’s xwidth x ywidth + xoffset + yoffset all mashed together (or instead of + I imagine you can also use -).

The only problem with this solution is that it’ll put all clone windows on the same monitor. Even though this satisfies my specific use case, I still want to match windows depending on the number of previous also-matched ones still active. For example I can imagine something akin to a tiling window manager on a particular workspace with terminal emulators, except driven by Devilspie and in just about any WM there is (although one might be able to work around that in this particular example with some bash scripting).

Comments (1)

VLC: Make Clone Filter Default

VLC ignores some of its GUI settings. Luckily it has easy, plain text configuration.

Despite enabling the clone filter in advanced video settings, VLC doesn’t seem to want to start with the clone filter enabled. No problem, just open up ~/.config/vlc/vlcrc and look for:

# Video output filter module (string)
#vout-filter=

Replace it with:

# Video output filter module (string)
vout-filter=clone

That’s it. Now VLC will always start with a clone. If you want more clones than the default 2 and VLC ignores the GUI settings as well, or VLC is ignoring some other GUI configuration, now you know where to look for it.

Comments (3)

On Balls

For some reason male genitalia came up a couple of times in the past week, so I might as well share what I learned about German balls and repeat my plea for not only the acceptance, but the embrace of the word ballsack.

On Wimpsthe Weak Balled

The author of some book claimed that German has no word for wimp. Someone else replied that Weichei carries the load perfectly, but that it’s not something you’d put on the cover of a children’s book. I wondered why, because “I always thought it referred to how easy it is to break an egg: a metaphorical reference to how easy it would be to break a Weichei’s confidence.” As it turns out, because Eier doubles as slang for testicles in German, it actually means as much as weak ball(s).

This misunderstanding might’ve occurred because “In Dutch there’s the expression een zacht eitje. Saying ‘he’s a soft egg’ means ‘he’s a wuss/wimp,’ and there’s another usage, ‘it’s a soft egg,’ meaning ‘it’s a piece of cake’ (as in ‘it’s easy,’ but translating an idiom with another certainly seems more appropriate).”

On Ballsacks

A few days later, someone remarked that they felt embarrassed because their kid used the word “ball sac [sic].” I replied,

Ballsack is a perfectly ordinary Germanic word for a part of the male anatomy. Some people seem to prefer the Latinate scrotum, but I disprefer it. In Dutch as well as German the respective words balzak and Hosensack (lit. pants bag or perhaps more appropriately, pants sack) are perfectly ordinary words, and indeed the standard words for referring to the ballsack. If anything, saying scrotum carries negative connotations in Dutch. As a fellow speaker of a Germanic language, I implore you not to continue this treachery and disrespect toward our ancestors and to proudly scream ballsack from the roofs!

While a humorous veil covers what I wrote, I’m hardly kidding.

Comments