
Posted by
Wicher
Topic:
Umeå
February 12th
2010
Bijna een jaar geleden vertrok ik naar Zweden om een paar maanden in Umeå te gaan wonen. Nu zat ik in de foto’s te rommelen (heimwee?) en sommige daarvan zijn best aardig als je benieuwd bent naar hoe het daar was/is.
-
- Uitzicht vanuit studentenkamertje
Met driedubbel vensterglas. Voor de mensen uit de Randstad: die malle palen met groene frummels zijn zgn 'bomen'.
Gemaakt: 2009-03-24 09:13:16 2592 x 1944 Uitzicht vanuit studentenkamertje
-
- Huisgenootjes en chocoladecake
Als je Zweden een zak meel geeft zijn ze niet meer te houden. Dan ontstaat er cake of taart of koek.
Gemaakt: 2009-04-06 20:52:36 2592 x 1944 Huisgenootjes en chocoladecake
-
- Meer naast m'n huis. Niet duiken hè!
't Is niet zo heel diep. Wel goed zwemwater — zodra het weer vloeibaar is.
Gemaakt: 2009-03-22 17:37:29 2592 x 1944 Meer naast m'n huis. Niet duiken hè!
-
- Dan maar ijsvissen
Gemaakt: 2009-03-17 14:57:52 2592 x 1944 Dan maar ijsvissen
-
- Of liggen
Gemaakt: 2009-03-17 15:01:35 2592 x 1944 Of liggen
-
- Voetpaden worden loopgraven
Gemaakt: 2009-03-17 15:22:04 2592 x 1944 Voetpaden worden loopgraven
-
- Fietspaden worden bobsleebanen
Gemaakt: 2009-03-17 15:52:18 1944 x 2592 Fietspaden worden bobsleebanen
-
- Dus afgraven die sneeuw
Gemaakt: 2009-03-17 15:54:10 2592 x 1944 Dus afgraven die sneeuw
-
- Maar hier dan weer niet, want dit is de stadsskipiste
Gemaakt: 2009-03-17 15:33:24 2592 x 1944 Maar hier dan weer niet, want dit is de stadsskipiste
-
- Bomen tussen de gebouwen
Gemaakt: 2009-03-17 16:01:49 2592 x 1944 Bomen tussen de gebouwen
-
- Gebouwen tussen de bomen
De stad is in een bos gebouwd. Er zijn dus veel eekhoorns en vogeltjes.
Gemaakt: 2009-03-19 16:54:09 2592 x 1944 Gebouwen tussen de bomen
-
- Parkeren vergt extra aandacht
Gemaakt: 2009-03-21 08:03:08 2592 x 1944 Parkeren vergt extra aandacht
-
- Bevroren rivier, vaselinewangetjes
Gemaakt: 2009-03-24 16:57:15 2592 x 1944 Bevroren rivier, vaselinewangetjes
-
- Van de andere kant
Gemaakt: 2009-04-13 17:50:53 3264 x 1832 Van de andere kant
-
- Koud badhuis lijkt me geen succes nee
Gemaakt: 2009-03-18 19:01:24 2592 x 1944 Koud badhuis lijkt me geen succes nee
-
- Waarom niet, eigenlijk?
Gemaakt: 2009-03-18 17:32:31 2592 x 1944 Waarom niet, eigenlijk?
-
- Ridders!
Gemaakt: 2009-04-29 16:03:16 3264 x 2448 Ridders!
-
- Barbecueue aan het meer. Rechts aan de horizon mijn huis.
Gemaakt: 2009-04-18 19:59:44 2592 x 1944 Barbecueue aan het meer. Rechts aan de horizon mijn huis.
-
- Brandhout wordt door de gemeente bijgevuld (!)
Gemaakt: 2009-04-18 20:01:42 2592 x 1944 Brandhout wordt door de gemeente bijgevuld (!)
-
- Mooi hoor
Gemaakt: 2009-04-18 20:03:08 2592 x 1944 Mooi hoor
-
- Koud ook wel
Gemaakt: 2009-04-18 23:04:27 2592 x 1944 Koud ook wel
-
- IJsvissen: gaatje boren in een rivier
Gemaakt: 2009-04-19 11:34:23 1944 x 2592 IJsvissen: gaatje boren in een rivier
-
- En dan maar wachten
Gemaakt: 2009-04-19 12:23:54 2592 x 1944 En dan maar wachten
-
- 23 april: Sneeuwnegeerdag (Universiteitsbibliotheek)
Hup, truien uit. De grond begint te ontdooien. Over de campus ruisen smeltwaterbeekjes.
Gemaakt: 2009-04-23 12:32:25 2592 x 1944 23 april: Sneeuwnegeerdag (Universiteitsbibliotheek)
-
- Dag ijs!
De Umeälven voert ijs uit Lapland af.
Gemaakt: 2009-04-24 16:47:08 2592 x 1944 Dag ijs!
-
- Verliefde meeuwen op reis
Naar Finland!
Gemaakt: 2009-04-25 16:15:38 2592 x 1944 Verliefde meeuwen op reis
-
- Lui fietswassen
D'r zat overal gravelslijpsel op-, aan- en ingekoekt. Hierna niet meer.
Gemaakt: 2009-06-18 16:09:18 2592 x 1944 Lui fietswassen
-
- 16 mei, weekend hiken: Höga Kusten.
Ontluikende knoppen.
Gemaakt: 2009-05-16 16:29:16 2592 x 1944 16 mei, weekend hiken: Höga Kusten.
-
- Finse mee voor de humor
Gemaakt: 2009-05-16 17:23:11 1944 x 2592 Finse mee voor de humor
-
- Deed het ook maar voor het eerst
Gemaakt: 2009-05-16 13:22:19 2272 x 1704 Deed het ook maar voor het eerst
-
- Boswandelaarsinfra
Je kunt er zo in en het kost niets. Met dank aan de Zweedse staat.
Wel zelf houtjes hakken voor de kachel.
Gemaakt: 2009-05-16 20:13:49 2272 x 1704 Boswandelaarsinfra
-
- mmmüsli
Sloom ontbijten met warme melkpoedermelk.
Gemaakt: 2009-05-17 11:06:27 2592 x 1944 mmmüsli
-
- Sneeuw+meer= adembenemende ochtendduik.
Gemaakt: 2009-05-17 12:24:02 1944 x 2592 Sneeuw+meer= adembenemende ochtendduik.
-
- Ödla, nog sloom van de kou
Volgens M. een zootoca vivipara, en dat er niet zo veel reptielen rond de poolcirkel uithangen.
Gemaakt: 2009-05-17 12:37:22 2592 x 1944 Ödla, nog sloom van de kou
-
- Hierom heet het Höga Kusten
Post-Glacial Rebound. Eustacy. Toppen van 300m. En het staat op de UNESCO-werelderfgoedlijst.
Gemaakt: 2009-05-17 13:10:35 2272 x 1704 Hierom heet het Höga Kusten
-
- Betekent dus dat je soms omhöga moet
Gemaakt: 2009-05-17 13:42:55 1704 x 2272 Betekent dus dat je soms omhöga moet
-
- ravijnen en alles
Gemaakt: 2009-05-17 13:58:03 1944 x 2592 ravijnen en alles
-
- Kraakhelder meertje
De meeste meertjes hebben een theekleur door organische zuren. Maar hier zit veel kalk in de rotsen dat die zuren bindt.
Gemaakt: 2009-05-18 12:18:02 2592 x 1944 Kraakhelder meertje
-
- Bevers: Nature's Hooligans
De beekdelta waar deze detailfoto is genomen was een enorme puinzooi. Ze knagen driekwart van de bomen om en klooien met dammen (die dan weer doorbreken). Het leek wel een crashsite.
Gemaakt: 2009-05-17 15:45:29 2592 x 1944 Bevers: Nature's Hooligans
-
- En
Door de schone lucht en het natte, koude klimaat groeien hier veel (korst)mossen en zwammen. Lange slierten aan boomtakken maken het bos zeer sprookjesachtig. (Maar dit is geen tak.)
Gemaakt: 2009-05-17 14:33:58 2592 x 1944 En
-
- heel veel
Door de schone lucht en het natte, koude klimaat groeien hier veel (korst)mossen en zwammen. Lange slierten aan boomtakken maken het bos zeer sprookjesachtig. (Maar dit is geen tak.)
Gemaakt: 2009-05-17 14:33:10 2592 x 1944 heel veel
-
- (korst)mos
Door de schone lucht en het natte, koude klimaat groeien hier veel (korst)mossen en zwammen. Lange slierten aan boomtakken maken het bos zeer sprookjesachtig. (Maar dit is geen tak.)
Gemaakt: 2009-05-18 14:08:15 2592 x 1944 (korst)mos
Tags: foto, höga kusten —

Posted by
Wicher
Topic:
Tech
February 5th
2010
Some quick numbers for those looking for performance figures on the CESA crypto accelerator. Like I was, since my SheevaPlug has one. From the kernel config:
CRYPTO_DEV_MV_CESA
This driver allows you to utilize the Cryptographic Engines and Security Accelerator (CESA) which can be found on the Marvell Orion and Kirkwood SoCs, such as QNAP’s TS-209.
Currently the driver supports AES in ECB and CBC mode without DMA.
Whether the accelerator will be used depends on whether an application uses the in-kernel crypto algorithms. OpenSSL does not unless it is explicitly enabled to use a certain accelerator, such as is the case with the Via Padlock engine. So this particular engine won’t let your SSH run faster. But it will speed up device mapper crypto if you use an AES cipher.
Right, let’s get on with it.
#uname -a
Linux sheeva 2.6.32-gentoo-r3 #3 Thu Feb 4 23:02:42 CET 2010 armv5tel Feroceon 88FR131 rev 1 (v5l) Marvell SheevaPlug Reference Board GNU/Linux
Quick & oh-so-dirty way of getting a RAM-backed block device (that is, if you don’t have swap enabled):
#mount -t tmpfs tmpfs /mnt/tmp/
#dd if=/dev/zero of=/mnt/tmp/blob bs=1M count=224
#losetup /dev/loop0 /mnt/tmp/blob
#cryptsetup -c aes -h sha1 -d /dev/urandom create test /dev/loop0
First we test without CESA.
#dd if=/dev/zero of=/dev/mapper/test bs=1M count=224
234881024 bytes (235 MB) copied, 41.858 s, 5.6 MB/s
Only 5.6 MB/s and the [kcryptd] kernel process is having your CPU for lunch.
Enter CESA:
#dmsetup remove test
#modprobe mv_cesa
#cryptsetup -c aes -h sha1 -d /dev/urandom create test /dev/loop0
#dd if=/dev/zero of=/dev/mapper/test bs=1M count=224
234881024 bytes (235 MB) copied, 18.0525 s, 13.0 MB/s
13.0 MB/s and there’s a new kernel process, [mv_crypto]. It’s eating about three times as much CPU as [kcryptd]. That means it’s offloading, which is good. The results are consistent over time so let’s say there’s a 2.5-fold performance gain.
The loop device setup causes some overhead. Out in the wild you’ll get about 19 MB/s writing to USB HDD. Cheers!
Tags: benchmark, sheevaplug —
January 31st
2010
There are times you need to connect to ‘dirty’ networks such as public WiFi hotspots. Hopefully you’re ensuring that sensitive information is encapsulated in transport layer security enabled protocols such as SSL, because anyone on the same link (in the case of WiFi, that’s the air surrounding you. A vacuum will do, too, but that’s less common) can listen in on the traffic you’re sending. With SSL encapsulation such as HTTP over SSL (https://), your traffic can still be read — but for those who do it’s an extremely boring read because they don’t know the session key, only you and the other endpoint do. Hopefully.
One particularly nasty thing that can happen to you is when your machine is subverted into using the attacker’s machine as the router. That is known as ARP poison routing. The attacker can proceed to not only read the traffic coming from your machine (which, on a shared medium, could be done anyway), or read the traffic going into your machine (again: on a shared medium, that could be done anyway), but the attacker can now also modify the traffic between you and the rest of the non-local network, e.g., the internet, in both directions. And that’s when he can really go to town with your traffic. Injecting a javascript keylogger into all the webpages you visit. ‘Sidejacking‘ your sessions, so he does not even need to know your passwords, just your session cookies — which you happen to transmit with every page request.
All possible unless you use transport layer security, which is tamper-proof once properly set up. Once properly set up. But setting up can have problems of itself — there are ways of preventing you ever going from HTTP to HTTPS. If you know a thing or two about HTTP and SSL you’ll be delighted to learn about Moxie’s very evil but very clever ways of doing so.
Anyway, some level of security can be achieved if you tell your machine to ignore any messages sent to you from the other machines on the local network. That includes messages that will make your machine believe that the router has suddenly changed its physical address — which is quite unlikely to happen, but those messages are exactly the type of message an impersonator would send you. Of course we’d need to whitelist the routers of the network, otherwise we can’t get traffic out of it and onto other networks. DNS resolvers will need whitelisting too, unless you’re running one on your own machine (probably not).
Not openly announcing your presence may also be something you wish for. If you have ever been on a network with a Mac user you have probably seen them popping up in your Zeroconf service browser as “Firstname Lastname’s iSomething”. Let’s cut down on that kind of promiscuity, too. But you should understand now that you can not actually hide unless you turn off your WiFi. Shared medium, remember?
I prepared a simple script to accomplish the above. I’ve used ip from the iproute2 package instead of sticking to old-school route, ifconfig, arp & co. And I must say ip neigh flush nud stale has a poetic ring to it, wouldn’t you agree?
Take note: this will only protect you from some kind of attacks, and only partially. An attacker has a window of opportunity between your machine getting assigned a DHCP lease and you running this script, for instance. Or maybe the access point is rigged. Actually all protection other than end-to-end encryption combined with mutual authentication is pretty useless on shared networks ;-)
Here’s the script. Linux-only. If you want to use it, get the latest version from my public repository.
#!/bin/bash
# arpshield 0.2
# Protects against ARP poisoning and cloaks your machine for all
# local link devices but the router(s) and the DNS server(s).
# Whitelisting DHCP servers also works if you use the dhcpcd program
# to obtain DHCP leases.
# This program is of no help if your setup is already poisoned.
# Have a look at ArpON (http://arpon.sourceforge.net/manpage.html) if
# you need more extensive protection.
#
# Needs 'ip', 'awk', 'sed', 'arptables', and 'arping' and expects
# them on $PATH. Needs appropriate privileges (so use sudo).
# Takes a network interface as an argument. The network interface
# should be up and configured. If no argument is given, clear all
# rules. Obviously you should do that before connecting to a new
# network.
#
# Copyright 2010 Wicher Minnaard (wicher@gavagai.eu)
# License: Creative Commons Attribution-Share Alike 3.0
# Do you use dhcpcd for aquiring DHCP leases? And is it running?
dhcpcdLEASEFILE="/var/lib/dhcpcd-${1}.info"
dhcpcdPIDFILE="/var/run/dhcpcd-${1}.pid"
test -f ${dhcpcdLEASEFILE} && test -f ${dhcpcdPIDFILE} && source ${dhcpcdLEASEFILE}
# In case you lack the luxury of dhcpcd, where is your resolv.conf?
RESOLV="/etc/resolv.conf"
# No user-servicable parts below this line.
DEV="${1}"
# I know, I know. But if your routing table contains 0.333.456.789 you have bigger problems ;-)
IPREGEX="\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}"
# Register
MACreg=""
# If not run as root, bail
[ "$(id -u)" != "0" ] && echo "You need root privileges to modify networking parameters. Exiting." 1>&2 && exit 2
getmac(){
# sets MAC register by IP. Sets to nil, if the MAC is not on the local link.
getMAC=$(ip neigh show ${1} | awk '{print $5}')
if [ -z "${getMAC}" ]; then
arping -c1 -I ${DEV} ${1} > /dev/null 2>&1
getMAC=$(ip neigh show ${1} | awk '{print $5}')
fi
MACreg=${getMAC}
}
allow(){
# Whitelists traffic to and from particular IP+MAC pairings and
# adds them to static ARP.
IP=${1}
MAC=${2}
if [[ -n "${IP}" && -n "${MAC}" ]]; then
arptables -A INPUT -s ${IP} --source-mac ${MAC} -j ACCEPT
arptables -A OUTPUT -d ${IP} --destination-mac ${MAC} -j ACCEPT
ip neigh replace ${IP} lladdr ${MAC} nud permanent dev ${DEV}
fi
}
if [ -n "${DEV}" ]; then
# whitelist the routers
test -z ${GATEWAYS} && GATEWAYS=$(ip route show dev ${DEV}| sed -n "s:.* via \(${IPREGEX}\).*:\1:p")
for GWIP in ${GATEWAYS}; do
MACreg=""
getmac ${GWIP}
allow ${GWIP} ${MACreg}
done
# whitelist the DNS servers
test -z ${DNSSERVERS} && DNSSERVERS=$(sed -n "s:^nameserver \(${IPREGEX}\):\1:p" ${RESOLV})
for DNS in ${DNSSERVERS}; do
MACreg=""
getmac ${DNS}
allow ${DNS} ${MACreg}
done
# if using dhcpcd, we can whitelist the DHCP server too
test -n ${DHCPSID} && getmac ${DHCPSID} && allow ${DHCPSID} ${MACreg}
# set default policy to DROP
arptables -P INPUT DROP
arptables -P OUTPUT DROP
# clear out non-hardcoded ARP cache entries
ip neigh flush nud reachable
ip neigh flush nud stale
else
# No argument given, so clean up.
arptables -F
arptables -P INPUT ACCEPT
arptables -P OUTPUT ACCEPT
ip neigh flush nud permanent
fi
Tags: arp spoofing, en_GB, security, wifi —

Posted by
Wicher
Topic:
Rants
January 24th
2010
Ik ben kwaad. Sacha vertelt waarom:

Dus. We hebben een regering van gekozen volksvertegenwoordigers. Goede zaak zou je zeggen, want die maken beleid dat het algemeen belang dient. Het algemeen belang.
Maar wat doet je minister, Camiel Eurlings? Die gaat nog even exclusief aan de leden van één (1!) belangenvereniging vragen of het beleid hen wel kan bekoren, want zo niet, dan gaat-ie het natuurlijk niet uitvoeren. Maar het is potdorie een hamerstuk waar onze tweede kamer (die jou vertegenwoordigt) al achter staat.
Camiel houdt een privéreferendumpje. Waarmee wordt beslist of autorijden duur mag worden. En alle automobilisten zijn uitgenodigd! Moet je in Nederland een ANWB-partijkaart hebben om je stem uit te mogen brengen?
Die heeft niet iedereen. Marietje, die vanochtend op de fiets naar d’r werk nog door een Hummer de stoep op werd gedrukt, wil er niet eens een. En Camiel gaat dus niet aan oma Truus in d’r met vrachtwagenroet bedekte woning aan de Fijnstofallee vragen wat zij van auto’s vindt. En hij vraagt het ook niet aan kleine Kareltje die achter z’n Playstation kinderdiabetes zit krijgen omdat er buiten niks te spelen valt omdat z’n huis temidden parkeerplaatsen, blik, drukke wegen en andere automobielinfra staat.
Als je het deze mensen zou vragen mag het autorijden best ontmoedigd worden. Maar nee, er wordt een voorstel gedaan zodanig dat autorijders het mee eens zullen zijn — en dus zullen die er niet al te veel op achteruit gaan. Met andere woorden: dat is dus niet het voorstel worden dat er voor gaat zorgen dat jongere generaties een fijne leefomgeving tegemoet gaan.
Goed hee Camiel, draagvlak zoeken. Dat zouden we vaker moeten doen. Zo vind ik dus dat de regering aan de Vereniging Stinkrijke Bonusbankiers had moeten vragen of ze er eigenlijk wel mee akkoord gaan dat die pret aan banden gaat. En we zullen ook nog maar moeten zien of de Nederlandse Delinquentenbond instemt met beter toezicht op verlofregelingen. Ze mogen dan trouwens zelf dat privéreferendumpje organiseren en de stemmen tellen, net als de ANWB. Zo nauw nemen we het immers toch al niet met de integriteit van volksraadpleegmechanismen.
Camiel, als je e.e.a. wil toelichten (graag!), dan kan dat door hieronder je reactie toe te voegen.
Tags: kilometerheffing, politiek, rekeningrijden —

Posted by
Wicher
Topic:
Howto
January 10th
2010
Access remote X11 servers that have their TCP socket disabled
This happens to me regularly. Someone brings a machine along and I want to display some app, running on my machine, on their display. Networked X11 to the rescue, you say? No, their X11 server is started with ‘-nolisten TCP’ wich is the default on most modern Linux distros. Sadly, the TCP socket can’t be enabled ‘in-flight’ — if you decide you do fancy a TCP socket after all, you’ll have to restart your X server which may be a pain if you’re in the middle of something (besides, restarting is just plain uncool).
But there is a way to expose the Unix domain socket as a TCP socket, with the help of socat. The following examples all use bash, so if you run a different shell (if you don’t know, you probably aren’t) you may need to define environment variables differently.
Braindead Proof of Concept (BPOC)
Situation: You want to display an application running on a machine called w00t on another machine, called bling. There’s an X11 server running on bling, but it’s not configured to listen on any TCP socket. DNS is properly setup, so if you ping w00t from bling, you get replies from bling’s IP, and vice versa.
- On bling, find the domain socket of bling’s X11 server. Have a look in
/tmp/.X11-unix/. The socket’s name usually reflects its X server display number (which you can determine by running echo $DISPLAY in an xterm).
- On bling, run something along the lines of
socat TCP-LISTEN:6066 UNIX-CONNECT:/tmp/.X11-unix/X0
This will open up TCP port 6066 on all of bling’s network interfaces, connecting it to the Unix domain socket of the X server.
- In an xterm on bling, run
xhost +. You have now opened up your X11 server to the whole wide world, a silly thing to do. Anyone with access to the TCP socket can now read your keystrokes, read your window contents, click your mouse buttons…
- In an xterm on w00t, run
DISPLAY="bling:66" xclock. You may have noticed that 66 = 6066 – 6000 and indeed, by convention the TCP port number for a certain display is its display number + 6000. Anyhow…. yay, a clock! It’s displayed on bling, but running on w00t.
Improvements
- You may have noticed that in the BPOC, you can use the display on bling only once.
socat will allow only one client, and will exit once that client exits. In some situations, you may consider that a feature (it’s a one-time access grant), but in others you may not. If you want a reusable TCP socket, run something along the lines of
socat TCP-listen:6066,fork,reuseaddr UNIX-CONNECT:/tmp/.X11-unix/X0 which forks off a socat process for every TCP connection.
- You may not want to expose a TCP socket on all interfaces. Maybe you only want to expose a socket on the LAN interface, or on the localhost interface (and wrap the packets in an SSH tunnel). Well, you can, using the ‘bind’ option:
socat TCP-LISTEN:6066,bind=localhost UNIX-CONNECT:/tmp/.X11-unix/X0
Now tunnel it over SSH. On w00t, run ssh -L 6011:localhost:6023 bling. Now localhost:6011 on woot is actually localhost:6023 on bling which is actually /tmp/.X11-unix/X0 on bling. So on w00t you can start an xclock with its display on bling by running DISPLAY="localhost:11" xclock.
xhost + from the BPOC is braindead indeed. There are a couple things you could have done instead, there are good ways of tightening up your authorization scheme.
- First off, you don’t really need to run
xhost + if you properly set up X11 cookies, which you should. Here are some examples on using the xauth scheme, but take note: xauth generate will probably not work on recent X11 releases since the XSECURITY extension is disabled by default. Just use the same cookies on the client and the server.
- Run
xhost +w00t. That’s host-based authentication, which is stupid, but not as stupid as no authorization at all. Any user on w00t can now connect.
- Suppose that on bling (of course!) you’d run
xhost +SI:localuser:theuser with ‘theuser’ being the userID of the unix-user running the socat instance. Now from the point of view of the X server, any client connecting through socat will be coming from ‘theuser’ and will therefore be allowed access. Entertaining, but not much different from just running xhost +. It is something to keep in mind though! Many distros by default add the unix-user that started the X server to the authorization list. That user does not need a cookie. If you run socat as that user you will have the effect of running xhost + even if you run xhost -.
- Just run a nested X11 server, such as Xnest or Xephyr. This way you put untrusted users in a sandbox, preventing them from snooping your keyboard and windows. It’s the X11 equivalent of a chroot.
Tags: en_GB, socat, X11, xauth, xhost —

Posted by
Wicher
Topic:
Howto
December 10th
2009
Here’s a trick. Many laptop trackpads lack a middle mouse button. On a regular mouse input device, the middle mouse button is the scroll wheel, and when you press it down it emits a button event. In X11 this button event is used to paste the X selection buffer into the position right beneath the cursor (there lies sublime usability in this simple fact).
You can emulate a middle-mouse-button event by pressing the left and right mouse buttons at the same time. Since I lack the manual dexterity to do this on my tiny netbook trackpad I wanted to be able to do middle-mouse-button-paste with my keyboard. Well, that appeared to be easy to accomplish with the X11 Xtest extension for which the Xautomation collection includes a utility in the form of xte. If you’d enter xte 'mouseclick 2' in a terminal (within an X11 session, of course), you’d get the same effect as if you’d just pressed the middle mouse button. Only thing left is to add a keyboard shortcut to run this command; in my favourite window manager, XFCE, this can be done clickwise via the Settings Manager or simply by running something like xfconf-query -c xfce4-keyboard-shortcuts -p '/commands/custom/<Super>v' -s "xte 'mouseclick 2'". I can now paste my X selection buffer by pressing the funny ‘four-wobbly-squares key’ and ‘v’ simultaneously.
Tags: clipboard, en_GB, X11 —
December 10th
2009
Today we talk usability. Specifically, desktop interaction differences between the X11 windowing system and the windowing systems that come with those operating systems you can actually buy in a shop downtown.
Select – Copy – Positionyourcursor – Paste
Say I’d like to copy some text from some window (which may or may not have the input focus) into some other window (which also may or may not have input focus). This action is commonly called ‘copy-paste’. Copy-paste. That sounds like two steps, doesn’t it?
Let’s say both windows are visible on the current desktop. Outside the of the X11 world – say, on a Windows machine, you’d have to undertake the following steps:
- Drag-select the text in the first window.
- Press ctrl-c or click edit/copy.
- In the second window, click the position you where you want the text to be inserted.
- Paste the text with ctrl-v or edit/paste.
This is not “copy-paste”. This is “select-copy-positionyourcursor-paste”. Here’s how you do it on X11:
- Drag-select the text in the first window.
- Hover over (you don’t need to click[*]) the position you want the text to be inserted at in the second window and paste by clicking with the middle mouse button.
There. Copy-paste. There are two atomic actions involved with that. You can’t get this down to less than two. You need to specify what you want to copy, and you need to specify where you want to paste it. The X11 engineers understood this. I entertain the thought that they must have valued my time as well, put two and two together, and that this why we have the X selection buffer on X11[**] that makes copy-paste really copy-paste.
(Read the footnote. I will show that not all is smooth in X11-land with respect to clipboards.)
Window focus
Whenever I venture out of X11-land there’s something else I dearly miss. It’s the ability of an inactive window to receive cursor input events when the cursor is on top of it. It’s immensely useful. Consider the following scenario.
Let’s say you’re browsing the web and you stumble upon a page which you want to discuss with a friend. It’s a long page, so there’s going to be some scrolling. You open up an instant messaging window to chat with your friend. You’re short on screen real estate so the IM window partly occludes the browser window. Meaning the IM window is on top of the browser window.
What you want to do now is to scroll occluded pieces of webpage text into view. But you also want to continue to see what you’re friend is saying. On Windows, you simply cannot. If you want to scroll the browser window, you’ll have to activate it, which means it will be raised, which means it will be above your IM window, which means you cannot see what your friend is typing. On X11, you can[*]. If your mouse cursor is over the browser window you can use the scroll wheel to scroll text into view, without the browser window being raised. Meaning your IM window is still on top, meaning you can still see what your friend is telling you. In fact, the IM window still has input focus so you can scroll the browser window and continue typing messages to your friend, limited only by your manual dexterity.
[Update: Added video to illustrate Windows behaviour][***]
Extravagance
If you think these situations are exotic, here’s and extravagant example for you. Open a file browser (Windows Explorer) window. Expand some folder trees in the left pane until you get a scroll bar in this pane. Navigate to a folder which has a lot of files (C:\Windows will do nicely) so the file pane also receives a scroll bar. You now have two panes, both with a scroll bar, within the same application. Thing is, you can only scroll in one of them at the time! If you want to look around in a “non-active” folder pane, you first have to click it. But don’t just click anywhere! You have to take special care to click it somewhere that doesn’t change your view in the file pane — better not click (near) one of the folders! Now suppose you’d like to scroll some files in the file pane into view. Better “activate” the file pane first then. Again, take extra special care: don’t just click anywhere in the file pane because then you may lose any previously made selection. It’s perverse, it really is. This is all happening inside one single application window. And the folder pane actually does notice when I hover over it (it underlines folders) so why can’t I scroll the view, then? Perverse. The OS is wasting my time.
Sloppy focus on Windows
I remember activating this on Windows 95 and it appears it still works. You can have crude ’sloppy focus’ on Windows. Just hex-edit your UserPreferencesMask in the Registry (Half of the times that I’m doing anything remotely interesting on Windows, I find myself entering hex values. Why is that.).
Refreshing as this may be, this will not help you with any of the above scenarios:
- In the copy-paste scenario, you still can’t specify insertion position and insert into that position in one single action.
- In the IM-while-browsing scenario, your IM window loses input focus when you scroll the web page in the browser window.
- Windows Explorer cursor behaviour stays just as perverse as it was with the standard click-to-focus model.
But hey, at least Windows users have some choice (provided they understand regedit.exe and hex). On OS-X, you don’t have a choice at all because Apple understands usability better than you do. For instance, Apple knows you head will explode if they’d give you the option of resizing your application windows by pulling any border or corner. You know very well that you will only want to resize your windows by grabbing the bottom right corner and will thank Apple for protecting you against yourself. (No, you’re not allowed to rebut until you’ve read and understand this mountain of insight and humour.)
Footnotes
[*] Actually, this is dependent on the focus policy. X11 itself does not specify the focus policy. X11 strives to provide mechanism, not policy. Policy is implemented by the window manager, and there are many window managers available for X11. A couple of them provide a ‘click to focus’ policy. Many of them provide ’sloppy focus’ and/or ‘focus follows mouse’ policies. This page has some concise definitions and elaborates on focus problems encountered the different models.
[**] Most window managers also have a ‘clipboard’, running in parallel with the X selection buffer. The clipboard only holds stuff you put there explicitly, whereas the X selection buffer holds whatever text you last selected anywhere in the X11 session. Furthermore, both clipboards usually only accept character data. So if you select and copy some pixels in drawing program A, you can’t paste them in drawing program B. Program A will have a private clipboard to hold pixel data, and B has one of its own, too. If you stay within the realm of one particular desktop environment with applications specific to this desktop environment, you may actually be able to use the clipboard inter-applicationwise for both text and binary data. But in general, you can’t. This plurality confuses the hell out of newcomers.
[***]A video demonstrating the Windows scroll focus issue:

Tags: clipboard, en_GB, sloppy focus, usability, X11 —

Posted by
Wicher
Topic:
Code
December 9th
2009
Just finished up a 0.1 version of a LIRC (Linux Infrared Control) plugin for the Exaile media player. Now you can use your remote with Exaile efficiently. The plugin is in the public repository and is called Lircaile.
I haven’t touched Python much as of yet, but I’m pleased with it: it appears to be a consistent language. Well, here’s my 0.1 effort. I desperately wanted to have some fun with introspection, but I have the feeling the nested exception logic is a bit… unusual.
# A LIRC plugin for Exaile. Depends on pylirc from http://sourceforge.net/projects/pylirc/
# Copyright (C) 2009 Wicher Minnaard, http://smorgasbord.gavagai.nl / wicher@gavagai.eu
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
from xl import playlist, player, event
import pylirc, logging
LIRCAILE = None
def enable(exaile):
if (exaile.loading):
event.add_callback(_enable, 'exaile_loaded')
else:
_enable(None, exaile, None)
def _enable(eventname, exaile, nothing):
global LIRCAILE
LIRCAILE = Lircaile(exaile)
def disable(exaile):
pylirc.exit()
class Lircaile(object):
def polLirc(self):
"""Pops all queued signals off of the LIRC queue and hands them to
handleCode() for further processing."""
gopoll = True
while(gopoll):
code = (pylirc.nextcode())
if (code):
comval = code[0].split()
if (len(comval) == 1):
self.handleCode(comval[0])
else:
self.handleCode(comval[0], comval[1])
else:
# We're done, the queue is empty.
gopoll = False
return True
def __init__(self, exaile):
self.exaile = exaile
self.logger = logging.getLogger(__name__)
socket = pylirc.init('lircaile')
event.EventTimer(0.05, self.polLirc)
def handleCode(self, command, *arg):
"""Takes LIRC signals and uses introspection to try to find appropriate
exaile functions to call based on the name of the signal. """
if (command == 'chvol'):
self.exaile.player.set_volume(self.exaile.player.get_volume() + float(arg[0]))
else:
func = None
# Look for a matching playlist function
try:
func = getattr(self.exaile.queue, command)
except AttributeError:
# No? Then look for a matching player function
try:
func = getattr(self.exaile.player, command)
except AttributeError:
# No? Then we're out of options
self.logger.warning('No function to handle "'+ command +'" LIRC event')
if callable(func):
func()
Tags: en_GB, exaile, lirc, lircaile, remote —

Posted by
Wicher
Topic:
Tech
November 22nd
2009
Er was eens een handige networksoundserver gebruikmakend van PulseAudio en een USB-soundcard.
Dat werkte dan leuk. Voor een poosje. Soms duurde het poosje lang, soms duurde het poosje kort. Maar het eindigde altijd zo:
hub 2-0:1.0: port 2 disabled by hub (EMI?), re-enabling...
usb 2-2: USB disconnect, address 2
En dan ging ik maar weer de pulseaudio-daemon herstarten. Hmmpf. Frutselen aan de softwareconfiguratie mocht niet baten.
Op een dag ging de bel en zat ik net muziek te luisteren. Iemand gebruikte de elektrische deurontgrendelaar en flop, muziek weg, port disabled. Aha! Dat bleek reproduceerbaar te zijn.
Die deurontgrendelaar werkt met een flinke elektromagneet die ik op de 8V-aftakking van de meterkast heb aangesloten. Kennelijk geeft dat een lekkere optater aan het binnenshuiselijk stroomnet. Mijn versterker zegt ook PATS en geeft de stoot over z’n line-in door aan het USB-geluidskaartje, en die weer aan de interne USB-hub van de machine waar-ie aan hangt. De hub vindt dat onbehoorlijk en sluit de poort, en terecht. Met “(EMI?)” probeert de kernel te vertellen dat er misschien wel iets met elektromagnetische interferentie aan de hand is, maar ja, dat begrijp ik nu pas.
De oplossing blijkt om ook de versterker ook op mijn UPS (Uninterruptable Power Supply) aan te sluiten. Die UPS tovert lelijke rotstroom om in voorbeeldig sinusoïde prik.
Conclusies?
- Als je de hele dag met softwareproblemen bezig bent wil het wel eens voorkomen dat je een laagbijdegrondse oorzaak (zoals vieze rotstroom) over het hoofd ziet.
- Stroom kan vies zijn, en als er Gekke Dingen gebeuren, probeer dan eens een goeie UPS.
Tags: EMI, UPS, USB —
November 14th
2009
Instead of cleaning out the kitchen I’ve prepared two fortune modules and ebuilds to go with them. One contains quotes from “Fight Club”, both the movie and the novel. The other one contains the Slashdot history of the world (posted AC).
Get them here.
Teasers
From fightclub-0.1:
That old saying, you always kill the one you love, well look, it works both
ways.
– Narrator, “Fight Club” (novel)
From slashistory-0.1:
A.D. 1789: The French Revolution begins with a distributed denial of service
(DDoS) attack on the Bastille.
Tags: en_GB, fight club, fortune, slashdot —