Helping the environment
A lot of work is done in making linux suspend work better. For me it works perfect (from linux kernel 2.6.20 or so). Therefore I wanted to go a step further and let my class A, heavy power-using receiver switch off when my desktop computer suspends (to ram). And switch back on when my computer wakes up. The motivation is that I only listen music via my computer.
To achieve this I bought the Gembird Silver Shield, a USB-switchable power adapter. I was prepared to do some nice USB snooping and C programming to get this device working in linux, but (un)fortunately there was already a working utility for this device.
Configuration for suspend/hibernate is not so easy and documentation is sparse for the user mode utilities. Since it took me more than the usual googling I will summarize my conclusions here for later use. First the gnome-screensaver measures the idle time. After this timeout is expired the gnome-power-manager starts to measure his own timeout (so before suspend the two times will stack). When the gnome-power-manager times out it will look at the Inhibit flag. If there is no inhibiting (for example my rhythmbox pushes Inhibiting, because I do not want to suspend when music is playing) your computer will suspend.
Since a custom script should be added to switch the power-switch off via usb with sispmctl the suspend-backend is important. Gnome power manager can use multiple backends to go to suspend mode. This works via hal (the hardware abstraction layer). Configuration for this is in /usr/share/hal/information. HAL is responsible for calling the suspend-backend. The default suspend-backend on my machine is pm-utils. (which can be tested with pm-(suspend/hibernate/power-save etc.). I also have a package called hibernate (which can also suspend, confusing isnt' it?). A third one is suspend2 (which can also hibernate....). These backends have different ways of adding custom hooks.
To add a hook to hibernate I added a file called local in /etc/hibernate/scriptlets.d/. The API is as follows (ugly in my book):
# -*- sh -*-
UsbPowerSocketDown() {
/usr/bin/sispmctl -f1
}
UsbPowerSocketUp() {
/usr/bin/sispmctl -o1
}
AddUsbOptions() {
AddSuspendHook 10 UsbPowerSocketDown
AddResumeHook 10 UsbPowerSocketUp
return 0
}
AddUsbOptions
Pm-utils has a much nicer API. To add a custom hook add a file to /etc/pm/sleep.d . This uses init style ordering. So look in /usr/lib/pm-utils/sleep.d/ for a proper number. I needed to talk to the usb-bus AFTER the modules were loaded, so a number lower than 50. So I added /etc/pm/sleep.d/10usbpoweroptions with content like this:
#!/bin/bash
case $1 in
suspend)
/usr/bin/sispmctl -f1
;;
resume)
sleep 1
/usr/bin/sispmctl -o1
;;
esac
After all this fiddling it works like a charm! Now hopefully one standard will emerge; because how to achieve the same result with KDE I don't know. I had to manually patch rhythmbox to change calling (via dbus) the Inhibit method from org.gnome.powermanager to org.freedesktop.powermanagement (because i used a wrong combination of versions..), so this suggests a move in the right direction.
[Permalink] -- Filed under: [music] [linux] [science]
Dead on
Good presentation on captchas by google. See this video. The group that is headed by the prof doing the presentation should easily be able to break current current used image captchas if their statements are true...
Perhaps I like it because perfectly reflects my own opinion though ;-).
[Permalink] -- Filed under: [linux] [science] [web]
Faraway voice
Hacked a bit more on audio captchas lately, but the source is not in releasable form right now.. Anyway, I now recognize the audio captchas from microsoft 95% correct and from google (also blogger/blogspot) 60%+ by tweaking the segmentation. captchas.net (35%) and paypal.com (10%) are also doable, but some improvements are still needed.
Time to add some neural network learning.
[Permalink] -- Filed under: [linux] [science]
Foucault's Pendulum
These weeks, with much pleasure, I have been reading
Umberto Eco's Foucault's Pendulum. The writer truly knows a lot about
history, philosophy, literature, different cultures and is very erudite. So
besides enjoying the good plot, reading Foucault's Pendulum learns me a lot. However,
on one thing the writer is a bit off. In the beginning of the book the main
person tries to break into a computer by writing a (inefficient) computer
program which generates anagrams of 'JHVH'.
Accidentally two weeks before reading this passage I wrote for my DND group a small program which solves a similar question in general. Since this group is too lazy to solve puzzles, I put the program on line; it is called rotx. Perhaps someone can make good use of it. It finds all rotx puzzles (with x = [1..25]) which deliver again a known word.
So, for example layout is the 'encrypted' version of fusion (rot6, so a->h, b->i, c->j, d->i, e->k, f->l, etc.), curly -> wolfs, arena - river, etc.
In dutch some solutions are urnen -> lieve, opaal -> hitte, knijp -> bezag and kerk->gang.To use rotx you need a wordlist, for example as generated by aspell:
aspell --lang=en dump master | ./rotx - > rotated.txt
The output (in the example above copied to rotated.txt) contains all rotated words which can also be found in the original wordlist..
The first incarnation of the program was in bash/sed/tr and awfully slow. (I had to try though, "No premature optimization!"). It should take two weeks to process a 1.5 MB English wordfile. (Eco's Basic script should take what, years??). Enter C++ and STL. The direct approach (rotating all words through the entire alphabet and looking all results up in the original list) should still take around 20 hours. So I cooked up an algorithm which uses more memory, but finishes in approximately 15 seconds on my old and crusty AMD duron 850!
The source can be found at /downloads/rotx.cc.html.
[Permalink] -- Filed under: [linux] [science]
Let's stick together
As can be seen on my software page, I started a new command line music player, called mms. It depends on noxmms and is a fork of xmms-shell. It is written in C++ and is public domain software.
[Permalink] -- Filed under: [linux] [science]

