You know that your health took a bad turn when…

… your medical records folder is ten times thicker than the job contracts folder. I was cleaning up through the paperwork yesterday and today, and there are so many things.. Luckily I have most of my CT scans in digital format, beside the last one I did at the ER last week, and a cerebral CT from a few months ago. But the release paperwork I had only in printed form, which I needed to scan and “PDFize” on Tuesday to send to my GP — nice to have one who’s reachable via e-mail.

It’s the scanning that actually made me think a bit. I have the scanner a bit far from my workstation; to scan a five pages document I have to prepare the scanimage command in batch mode on the workstation, then walk all around my desk to get to the scanner, and then get my arm around the monitor to press the return key on the keyboard to start the scan.

The annoying thing is that the scanner has four buttons on it, that should be made just for the task of starting the scan. Unfortunately these buttons don’t work out of the box on Linux at all. There is a package, called scanbuttond that polls for them through libusb and then execute a custom script when they are pressed. But as you can guess, polling means it uses a lot of CPU, and the fact that they run a generic script makes it less integrable in a desktop environment. Of course it would be easy to port scanbuttond to submit the read buttons back into the kerel input subsystem so that they appear as generic events, but… I think this should be a task well suited for a kernel module, hooking them up directly in the input subsystem, so that evdev could pick them up and then a program could just wait for them as shortcuts to have some action.

I tried looking into writing something before, but I ended up stuck in a problem: would a kernel module interfacing with the scanner interfere with libusb access by sane itself? Last time I enquired Greg KH, he asked me to proivde lsusb -vv output but, sorry Greg, work piled up and I forgot about all of it (until yesterday when I had to scan some more documents). Well, if anybody wants to take a look, this is it for my current scanner:

Bus 001 Device 003: ID 04b8:0121 Seiko Epson Corp. Perfection 2480 Photo
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass       255 Vendor Specific Subclass
  bDeviceProtocol       255 Vendor Specific Protocol
  bMaxPacketSize0        64
  idVendor           0x04b8 Seiko Epson Corp.
  idProduct          0x0121 Perfection 2480 Photo
  bcdDevice            0.00
  iManufacturer           1 EPSON
  iProduct                2 EPSON Scanner
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              16
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass       255 Vendor Specific Subclass
  bDeviceProtocol       255 Vendor Specific Protocol
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0001
  Self Powered

Can anybody tell if it would be possible for a kernel module and sane to access it at once? :)

If there is the chance, I might look at it once I feel better. I haven’t written or touched a kernel module in so much time that I’m feeling like doing some work in that regard. And the code to actually get the data out of the scanner should be present in scanbuttond already, it’s just a matter of getting it “pushed in” rather than “polled for”.

Once I could get the buttons working, I’d probably be working on a GTK-based frontend for scanimage with handling of those, so I could just use those rather than having to set it up manually. Although the nice thing of scanimage is that, through that, tiffcp and tiff2pdf, I can quickly create a multi-page PDF of the scan (the first command creates a multi-page TIFF file, the second converts it to PDF), and if I do the scan in lineart (the perfect solution for B/W text) it also is tremendously small in size. I should try to have the same result with my frontend. My idea would be a light frontend written in Ruby, calling the commands directly.

Oh well, at any rate, this will have to wait till I’m feeling really better, or maybe it’s just unfeasible because of the way it’d need to access the scanner from kernel and libusb.

My thoughts about Synergy

I was suggested more than once lately, especially after my posts with multiseat, to try out Synergy. Well, I did :)

It’s quite an interesting program, and it actually saves me from having to use two mouse at once every time. Too bad I needed a mouse anyway to get the second seat, or I would have saved quite some money, too.

There are a few problems with it, though, for instance the server crashes from time to time, stopping access from the clients.

It’s unfortunate that the project development has slowed down, as it would be quite an interesting thing. Having better support for OSX for instance would be nice, as it is, part of my keyboard does not work on the laptop because there are keys that are NOT on the laptop.

One way to achieve better integration would be, I suppose, to make it act as an input driver on OSX. Using the same protocol, but rather than having a daemon, having an input driver that “installs” its own keyboard and mouse. It would probably then allow to use as many keys as the server has.

A similar piece of software could be done under X11: an Xorg driver that handles the input as a virtual event. With such a software I could easily get rid of the keyboard and mouse that I reserved for the extra seat and leave it as a virtual device.

If only Xorg would be more easily shared between instances (less use of .data.rel for instance) it would be quite interesting to use the monitors with three separate instances; this way it would handle dpms differently on a per-monitor basis, and shut down the extra monitors when not needed; as it is unless I do it on my own, the monitor at my left is always on, as it’s handled by the same session as the central one.

Well, if anybody wants to start working on it, it would be appreciated :)

I’ve killed X

Note (2020-05-03): this post was recovered thanks to Internet Archive’s Wayback Machine. Consider donating to the Archive to make sure content, important or not, is not lost in the continuous software update cycle.

Ok following my last entry, today I took the combination of situations to go finding a new keyboard with my sister.

The keyboard which I chosen between the not-so-vast-but-neither-too-small selection I had on the shop I gone is a Logitech Cordless Desktop LX700; it has a lot of extra keys which I really really like, and also if the mouse is now my third optical mouse at home, it’s quite handy.

Unfortunately, I had a couple of problems trying to get it working. Well actually the base keyboard works fine, but as I paid it a bit too much (€99.95), I really really want it to work completely, and this requires the use of all the keys, of the zoom pad, of the mouse extra buttons and so on.

It has USB connection and it’s seen as two HID devices, sending different kinds of events depending on the keys. And this is a good thing because it can be completely remapped, and not only remapped when the keys aren’t strictly bound like it was on the old keyboard.

The scroll wheel works fine, too.

The problem now is that the extra keys aren’t seen by the kernel (showkey outputs nothing), and they are just available with the evdev driver (I’m using Xorg 6.8.99.8 so that’s not really a problem), but also using that I had problems.

For example the zoom pad was registered as V and C (instead of zoom+ zoom-).. searching, I found that the code sent by zoom+ (0x12F) was a combination of 0x01 and 0x2F which is the code of ‘V’. This because Xorg uses 8-bit keycodes in the input layer and 32-bit keycodes in the external interface.

I’m currently building an xorg where all the keycodes variable are 16-bit but I’m not sure if that would work completely.. my first try gone wild and rejects every key from the keyboard itself.
I hope this will come to something good as supporting new keyboards like that is something really really interesting and I don’t want to use just partially something which costed me almost €100..
Last time I bough a keyboard, I managed to have the scroll wheel working with the help of Vojtěch Pavlík (thanks to jkt for the correction, I know what it means seeing the name “wronged” by ascii-reduction), maybe this time I’ll manage to have the extra keys working.

When this will work, I’ll recommend this keyboard to everyone as it seems to be quite good as keypresses and as general quality… just it doesn’t completely work on Linux for now :P