Thursday, 24 June 2010

Gray boxes in evince

If you're having a weird problem with evince showing gray boxes instead of text in some pdfs, the problem could well be a bug in cairo.


After some help from "danigm" on the #evince channel on irc.gnome.org, I found that the bug disappeared on upgrading libcairo to 1.9.8 (which is currently in debian experimental).


Anyway, hopefully the next person who searches google for grey boxes in evince or indeed gray boxes in evince should find the solution!

Friday, 31 July 2009

Huawei E1550 on Debian

If you want to get the Huawei E1550 USB modem working with linux, here's what you need to do, with specific instructions for those on Debian.

modem-modeswitch


This utility is part of udev as of version 145. You need it because the E1550 has a clever double-identity: when you insert it at first, it masquerades as a mass storage device (usb id 12D1:1446). Upon running this magical command, it disconnects and reappears as an "E620 USB modem" (usb id 12D1:1001). Magic eh?

Firstly, you need to get the program. If you have udev 145, life is good. Unfortunately, the current debian unstable package is on version 141, which doesn't have it. Trying to manually install udev 145, I managed to break my X setup quite spectacularly, so I don't advise that. Fortunately, if you download the latest udev source (from
http://www.kernel.org/pub/linux/utils/kernel/hotplug/) and compile it, you'll find that the binary in the extras/modem-modeswitch directory works fine without the rest of udev 145. Note that to compile udev, you'll need some libraries. On debian, an incantation like apt-get build-dep udev should get them. To put it somewhere useful, one option is to run checkinstall from inside the extras/modem-modeswitch
directory and make a fake debian package for the meantime.

Now you've got modem-modeswitch installed, you want to try it! Pull up a spare terminal window and run something like sudo tail -f /var/log/syslog in it. This lets you know what's going on, since drivers tend to report stuff there when they initialise
themselves. Now run the following command /path/to/modem-modeswitch -v 0x12d1 -p 0x1446 -t option-zerocd. On my dongle (courtesy of 3), there's a green LED that flashes at first and then turns blue at this point. In any case, the syslog window should report a USB disconnect and then a new device. Running lsusb should show a line something like Bus 002 Device 003: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem (the first two numbers will probably be different: they're
just to say where it's connected).

If you've got this far, the confusing bit's over. Unplug the device again and we'll set things up to run modem-modeswitch by default.

udev


To do so, we need to create a udev rule to tell it to run when the device is plugged in. Create a file in /etc/udev/rules.d/ called something like 50-huawei1550.rules containing the following line

SUBSYSTEM=="usb", SYSFS{idProduct}=="1446",SYSFS{idVendor}=="12d1", RUN+="/usr/libexec/modem-modeswitch --vendor 0x12d1 --product 0x1446 --type option-zerocd"

This tells udev that when a device with USB id 12d1:1446 gets plugged in, it should run modem-modeswitch to change its mode. (This snippet came from somewhere on the web, but I've lost the reference). You probably need to restart udev here (/etc/init.d/udev restart) to enable your rule. Re-insert the device and cross your fingers... if everything works, it should change mode.


usb-serial

If you're using a distro kernel, you can probably ignore this, but I was running a home-built kernel which didn't have the usb-serial kernel module. You need it.

If you've got stuff right, lines like the following should appear in your syslog:

Jul 31 10:49:03 hake kernel: usbcore: registered new interface driver usbserial
Jul 31 10:49:03 hake kernel: USB Serial support registered for generic
Jul 31 10:49:03 hake kernel: usbcore: registered new interface driver usbserial_generic
Jul 31 10:49:03 hake kernel: usbserial: USB Serial Driver core
Jul 31 10:49:03 hake kernel: USB Serial support registered for GSM modem (1-port)
Jul 31 10:49:03 hake kernel: option 2-2:1.0: GSM modem (1-port) converter detected
Jul 31 10:49:03 hake kernel: usb 2-2: GSM modem (1-port) converter now attached to ttyUSB0
Jul 31 10:49:03 hake kernel: option 2-2:1.1: GSM modem (1-port) converter detected
Jul 31 10:49:03 hake kernel: usb 2-2: GSM modem (1-port) converter now attached to ttyUSB1
Jul 31 10:49:03 hake kernel: option 2-2:1.2: GSM modem (1-port) converter detected
Jul 31 10:49:03 hake kernel: usb 2-2: GSM modem (1-port) converter now attached to ttyUSB2
Jul 31 10:49:03 hake kernel: usbcore: registered new interface driver option
Jul 31 10:49:03 hake kernel: option: v0.7.2:USB Driver for GSM modems

Thursday, 30 October 2008

Science Education Website

Well, I'm lame and not really updating this. However, my mother has a terribly nice (ahem?) website at WAS Science, which she doesn't seem to be able to get web spiders to notice. It's a site full of science education resources including powerpoint presentations and worksheets.

Maybe some googly goodness from blogger will go her way.

Thursday, 26 July 2007

Quick book recommendation

This summer, I've got an undergraduate research bursary at our university's Systems Biology centre, which is wierd as I always viewed myself of more of a pure mathematician, but is absolutely fascinating.

I have jumped in at the deep end, however (my supervisor seems to think I know a lot more than I really do and maybe hasn't realised I haven't done any serious integration/differentiation or ODEs stuff since the first year...).

What I'm actually doing is looking at the response of Neurons to different types of presynaptic noise, which I am slowly learning more about. In particular, noise is random (well, duh) and so all of the models I end up with have Stochastic Differential Equations, which are typically quite unpleasant. For those interested, the toy models I'm playing with end up with Brownian motion in a harmonic potential.

So the book I'm recommending is:

Paul and Baschnagel, "Stochastic Processes, From Physics to Finance"

Don't let the reference to finance put you off - I've found it absolutely fantastic for explaining the basics of Wiener processes, brownian motion and so on. In particular, it is written for the scientist rather than the mathematician and so everything's done in the real numbers, rather than over wierd and wonderful probability spaces. I really believe that even if you want to learn stochastic integration properly as a mathematician, this is a worthwhile read, because you end up for a real feel for what's going on.

The book's published by Springer and is on Amazon here at the terrifying price of about £50 used, so you might want to try a university library!

Now back to work!

Thursday, 5 July 2007

Fun with xorg.conf

So I've finally got my ALPS / Synaptics touchpad working along with a compose key on debian (the ALPS touchpad comes with, among many other laptops, the Dell Inspiron 500m which I own).

The touchpad

For the touchpad, I need to thank this walkthrough along with this forum thread.

Before anything will work, you need to make sure that the evdev module is being compiled in your kernel (it wasn't) and is being loaded (that bit worked for free for me, but one comment on the above forum post suggested you needed to add it to /etc/modules). You can find the option under Device Drivers/Input Device Support/Event Interface in the kernel config (e.g. make menuconfig)


Now you need to edit your xorg.conf (found in /etc/X11). There are three things that you need to do:

  • Load the synaptics module

  • Add a new input device to ServerLayout

  • Declare the input device


In order to load the synaptics module, add a line saying:

Load "synaptics"

to the "Module" section. Mine now looks like:

Section "Module"
Load "glx"
Load "extmod"
Load "xtrap"
Load "record"
Load "GLcore"
Load "dbe"
Load "dri"
Load "type1"
Load "synaptics"
EndSection


Now adding a new input device to ServerLayout is simple - just choose a name (I called it "ALPS") and add the line

InputDevice "your name for it here"

to the ServerLayout section just below the line saying

InputDevice "Configured Mouse"


Finally, add the declaration for the input device. A version with no clever options set is:

Section "InputDevice"
Identifier "ALPS"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/input/mouse1"
Option "Protocol" "evdev"
Option "SHMConfig" "on"
EndSection

(note that the identifier has to agree with the name you chose earlier). For a much more thorough list of settings you might wish to see the third page of the debuntu article here.

Assuming you got everything right, you should now be able to restart your X server and get exciting touchpad support. Note that to restart the X server, the best practice is to exit (gracefully) any open programs, log out of whatever desktop environment you're using and when you get to the display manager (xdm,kdm,gdm or whatever) hit Ctrl-Alt-Backspace.

The Compose Key

This is really simple, but it makes life much easier when writing auf Deutsch on an english keyboard. In your InputDevice section corresponding to your keyboard, add the line:
Option "XkbOptions" "lv3:ralt_switch, compose:ralt"
The relevant section in my xorg.conf now looks like this:

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "pc105"
Option "XkbLayout" "gb"
Option "XkbOptions" "lv3:ralt_switch, compose:ralt"
EndSection


Once you've restarted the X server, Alt-Gr S, S should give ß and you can have the fun of discovering umlauts, graves, circumflexes etc. yourself. It's a bit like a more logical version of the system they used in Microsoft Word.

Wednesday, 13 June 2007

Backing up your home to DVD with debian

I've finally got a DVD writer (external - it's a laptop) and it works quite amazingly well: no setup issues at all!

Now, the whole point of the exercise was that my Dell is getting a little dodgy (you have to press down hard around the power button to flex the PCB below in order to get it to boot!) and I wanted to back up my documents, sourcecode, emails etc. in case the worst should befall my poor old laptop. But I had a German exam the next day, and while I was burning the DVD I should also be revising!

In general, burning a data DVD on linux is easy. You get a copy of mkisofs and growisofs (on debian, this is easy: apt-get install dvd+rw-tools mkisofs). Then you call mkisofs on a directory tree to create an iso image (put it in /tmp!) and growisofs to write the lot to your DVD (I got the instructions here

Ahah, but not so fast! I wanted to do my home directory whilst xfce, claws-mail, firefox and probably a whole load of other processes were writing tiddly little bits to all my hidden dot-files and dot-directories in ~/ (you know, the ones like ~/.gnome and ~/.mozilla etc.). In fact, I didn't twig the first time and mkisofs threw a wobbly! Moreover, I didn't want to make another copy of everything because there's quite a lot of stuff and I didn't really have space for that on the harddisk partition.

So here's the solution:

First I made a folder called backmeup in my home directory:
mkdir backmeup
Then I moved all of the "normal" i.e. non-hidden files in my home directory into backmeup:
mv * backmeup
This will actually complain because at some point you've asked it to move backmeup into backmeup, but ignore the complaint - it did what we wanted! Now for the dot-files. We don't want to move them into backmeup, because some of the running programs would throw a wobbly, so we will actually need to copy this lot. Now, don't run cp -Rp .* backmeup/ because it'll go horribly wrong and try to make two copies of backmeup via the .. directory I think (disclaimer: Yes, this did go horribly wrong. And it took me 5 minutes to notice!)

Instead, call the following command:
cp -Rp `find -maxdepth 1 -name '.*' | sed '/^\.$/d'` backmeup
which is what we really wanted.

Now we're almost done! Just make the iso from the backmeup tree (no-one's going to be writing automatically to something called that!):
nice -n 19 mkisofs -r -o /tmp/rupert.iso /home/rupert/backmeup
The nice command is just to stop the job hogging the whole system.

... And write the iso to the disk:
growisofs -Z /dev/scd0=/tmp/rupert.iso

(clearly the device to which you write will need to depend on what the kernel calls it - I'm trying to do something clever with udev, but haven't quite got there yet!)

Wednesday, 6 June 2007

Ical subscriptions with orage

Orage looks to be an exciting program for my new Xfce desktop, but what good's a calendar if it can't subscribe to ical feeds from the internet?! Fortunately, I'm supposed to be revising at the moment, so have had an urge to hack code together...

And so we present a simple shell script to download .ics files periodically from the internet to your filesystem. The one nifty feature is that if the internet's down, this won't blat the current copies as using wget blindly would, which should be useful with my laptop.


There are probably more sophisticated systems, but I was going for the 25 minute job option. Firstly, we need a list of feeds - mine looked something like this:

## Lines must be either urls, blank, or start with a #.

# UK holidays
http://ical.mac.com/ical/UK32Holidays.ics

# NASA Space Missions
http://ical.mac.com/tonyfarley/SpaceMissions.ics

# Astronomical Events
http://hewgill.com/astrocal/astrocal.ics


The lines beginning with hashes really are comments - they get stripped by the downloading script, which uses wget:

#!/bin/sh

dir=/home/rupert/.icals/

for f in `cat $dir/feeds.list | sed -e '/^$/d' -e '/^\#/d'`
do
fout=$dir/`echo $f | md5sum | cut -f 1 -d ' '`.ics
tmp=`mktemp $dir/getfile.XXXXXX`
wget -q --tries=3 -O $tmp $f
if [ -s $tmp ]; then
mv $tmp $fout
else
rm $tmp
fi
done


To make it work, you need to call the first file feeds.list and set dir to a directory containing feeds.list and in which you'd like your downloaded .ics files to end up. The quickest way I could think of to give the files names was the md5sum of the url, so once you've got everything in place, set the executable bit on the script (which I called get_feeds.sh) and run it.

If all goes to plan, you should get some files called things like "5b7ed8afdd4a8f71525d0df0e47231e5.ics" appearing in $dir. Now we need to automate it: I used cron, so call crontab -e and add the following line to your crontab:

*/15 * * * * /home/rupert/.icals/get_feeds.sh

(well clearly, you'll need to make the directory right!) This calls the get_feeds.sh script every 15 minutes. Maybe we should slow that down, but I was testing!

Finally, use the new "Exchange Data" item on Orage's File menu to add a foreign file corresponding to the .ics you downloaded and you're away! Wahey!

Incidentally, the SVN orage that I downloaded this evening doesn't appear to be getting multiple foreign files quite right - if I can work out what's going on, I'll file a bug tomorrow!