ronny.haryan.to

Icon

Print: $9.50 — Online: free

D-Bus Multimedia Keys Plugin for Quod Libet

Since upgrading my Ubuntu desktop to Feisty my multimedia keys stopped working when using Quod Libet, although they work fine with Rhythmbox and Totem. This is because in GNOME 2.18 that comes with Feisty, gnome-settings-daemon ‘grabs’ all multimedia keys preventing other applications to capture them. Multimedia key press events are now being broadcast via D-Bus. Therefore applications that need to listen to those events could subscribe to the proper D-Bus interface. Other GNOME apps like Rhythmbox and Totem had picked up the changes and had been adjusted accordingly. That’s why they still work in Feisty. But Quod Libet is not a GNOME application, so this new method of multimedia keys handling that is specific to GNOME should not be implemented inside the Quod Libet core. This is documented in bug #43464 in Launchpad.

Joe Wreschnig, Quod Libet’s author, suggested that this could be implemented as a plugin. After an email conversation with him, and seeing a patch posted to the bug in launchpad, I started writing the plugin last night. Now the multimedia keys work again in Quod Libet. The plugin can be downloaded from launchpad or from here (rename to dbusmmkey.py). Simply put this file in ~/.quodlibet/plugins/events/ and enable it in Quod Libet.

PS. Python is so much fun!

Trash Those Penny Stock Spam

May God forgive all the spammers’ souls.

Meanwhile, I use this procmail recipe:

:0B
* ^Symbol: +[A-Z][A-Z][A-Z][A-Z]
* ^Current Price: +\$[0-9]\.
* Term Target( Price)?: +\$
/dev/null

This one recipe alone reduces my daily spam by about half! I get about 500 to 1,000 spam emails daily. This is the only reason I reactivated my procmail. My Bayesian filter, which has been working wonderfully for years now, caught all the penny stock spam just fine, it’s just that it’s really annoying and harder for me to go through these penny stock spam when checking my spam folder for false positives.

Mail Testing Tricks

Here are some MTA (mail server) tricks that I use at work for testing an email application that we’re working on.

I wanted to do a rough benchmarking on how fast our email app can pump messages to the MTA. Of course I don’t want to actually send the emails, I don’t care where it’s sent to or what the content is, the MTA should just accept then drop them straight away.

I’m using Postfix. So I have the email app send 50,000 emails to x@blackhole.localdomain, where x is a number between 1 and 50,000. You can also do this easily with smtp-source program that comes with Postfix. In /etc/hosts I added 127.0.0.1 blackhole.localdomain, and then I set $transport_maps to hash:/etc/postfix/transport and in /etc/postfix/transport I added blackhole.localdomain blackhole: and ran postmap /etc/postfix/transport. This will make everything sent to blackhole.localdomain to be sent via the ‘blackhole’ transport, which we need to define in master.cf as follows:

blackhole unix  -       n       n       -       -       pipe
    user=nobody argv=/bin/true ${user}

The mail logs should tell us whether it’s working or not.

Another thing that sometimes I wanted to do is to capture the actual emails sent after it reaches the MTA but without the MTA actually sending the mail to the recipients. This is to get a better picture of how the emails will look like to the recipients. This is useful, for example, to verify that headers, newlines, charset, encoding, MIME, etc. are generated correctly. With Postfix, I used content_filter and did something like this in master.cf.

pickup    fifo  n       -       -       60      1       pickup
    -o content_filter=dbgcapture
20025     inet  n       -       -       -       -       smtpd
    -o content_filter=dbgcapture
20026     inet  n       -       -       -       -       smtpd
    -o debug_peer_list=127.0.0.1,192.168.1.0/24
    -o content_filter=dbgcapture
dbgcapture unix  -       n       n       -       -       pipe
  flags=FR user=ronny argv=/usr/bin/tee -a /tmp/capture.mbox

Mails sent via SMTP to $inet_interfaces:20025 and sent via /usr/sbin/sendmail will be captured in /tmp/capture.mbox. Similarly, port 20026, with additional SMTP debugging in the logs. Port 25 still works as usual. If you don’t want /usr/sbin/sendmail to go to dbgcapture simply comment out the -o content_filter line right after the pickup line. Note that using /usr/bin/tee here may not be the most efficient/correct. It works most of the time, but it’s asynchronous and it doesn’t guarantee all mails will be written in the correct order (or at all) in the mbox. If you can suggest a better way with similar level of ease, please let me know.

I was also looking at capturing mails with Sendmail. It’s possible using MIMEDefang milter with action_quarantine_whole_email() followed by action_discard(). It works but somehow it ran slower than a snail. I’m not that familiar with Sendmail. Meh. No big deal. I left the tests running, I went home, and check the test results the next morning.

In the next few months we will be doing a lot more of this kind of tests, so I’m planning to do similar thing with qmail and Exim to cover a lot more base.

The Power of Sudo

So funny, it made me cry a little.

Courtesy link for the uninitiated.

Quod Libet and Mutagen

It started when I wanted to remove APEv2 tags from some of my music files. For some reasons Rhythmbox–or rather GStreamer–prefers using APEv2 tags over ID3v2 tags, and the current version of EasyTag in Ubuntu Dapper does not seem to support APEv2 tags. So I wanted to just remove the APEv2 tags altogether. Googling around lead me to mutagen-inspect which is part of the Mutagen library, which in turn is used by Quod Libet. I’ll talk more about Quod Libet later, it’s even more interesting than Mutagen.

Read the rest of this entry »

About

Ronny Haryanto is a technology addict/chef wannabe living in beautiful Melbourne, Australia.

Read more…

Follow Me on Twitter

Follow @ronny on Twitter where I post much more often than my blog.