Thursday, 5 December 2013

Using a Kobo Ebook Reader as a Gmail Notifier

A certain person that I know well does not read her emails very often and sees it as a chore to switch on the computer to see if she has any.  And no, I can't interest her in a smartphone that will do email for her....This post is about making a simple device to hang on the wall like a small picture next to the calendar so she can always see if she has emails to know if it is worth putting the computer on.

I was in WH Smith the other day and realised that they were selling Kobo Mini e-book readers for a very good price (<£30).   When you think about it the reader is a small battery powered computer with wifi interface, a 5" e-ink screen with a touch screen interface.    This sounds like just the thing to hang on the wall and use to display the number of un-read emails.

Fortunately some clever people have worked out how to modify the software on the device - it runs linux and the manufacturers have published the open source part of the device firmware (https://github.com/kobolabs/Kobo-Reader).   I haven't done it myself, but someone else has compiled python to run on the device and use the pygame library to handle writing to the screen (http://www.mobileread.com/forums/showthread.php?t=219173).  Note that I needed this later build of python to run on my new kobo mini as some of the other builds that are available crashed without any error messages - I think this is to do with the version of some of the c libraries installed on the device.
Finally someone called Kevin Short wrote a programme to use a kobo as a weather monitor, which is very similar to what I am trying to do and was a very useful template to start from - thank you, Kevin! (http://www.mobileread.com/forums/showthread.php?t=194376).

The steps I followed to get this working were:

  • Enable telnet and ftp access to the kobo (http://wiki.mobileread.com/wiki/Kobo_Touch_Hacking)
  • Put python on the 'user' folder of the device (/mnt/onboard/.python).
  • Extend the LD_LIBRARY_PATH in /etc/profile to point to the new python/lib and pygame library directories.
  • Add 'source /etc/profile' into /etc/init.d/rcS so that we have access to the python libraries during boot-up.
  • Prevented the normal kobo software from starting by commenting out the lines that start the 'hindenburg' and 'nickel' applications in /etc/init.d/rcS.
  • Killed the boot-up animation screen by adding the following into rcS:
          killall on-animator.sh
          sleep 1
  • Added my own boot-up splash screen by adding the follwing to rcS:
          cat /etc/images/SandieMail.raw | /usr/local/Kobo/pickel showpic 
  • Enabled wifi networking on boot up by referencing a new script /etc/network/wifiup.sh in rcS, which contains:
          insmod /drivers/ntx508/wifi/sdio_wifi_pwr.ko
          insmod /drivers/ntx508/wifi/dhd.ko
          sleep 2
          ifconfig eth0 up
          wlarm_le -i eth0 up
          wpa_supplicant -s -i eth0 -c /etc/wpa_supplicant/wpa_supplicant.conf -C         /var/run/wpa_supplicant -B sleep 2
          udhcpc -S -i eth0 -s /etc/udhcpc.d/default.script -t15 -T10 -A3 -f -q
  • Started my new gmail notifier program using the following in rcS:
          cd /mnt/onboard/.apps/koboGmail
          /usr/bin/python gmail.py > /mnt/onboard/gmail.log 2>&1 &
The actual python program to do the logging is quite simple - it uses the pygame program to write to a framebuffer screen, but uses a utility called 'full_update' that is part of the kobo weather project to update the screen.   The program does the following:
  • Get the battery status, and create an appropriate icon to show battery state.
  • Get the wifi link status and create an appropriate icon to show the link state.
  • Get the 'atom' feed of the user's gmail account using the url, username and password stored in a configuration file.
  • Draw the screen image showing the number of unread emails, and the sender and subject of the first 10 unread mails, and render the battery and wifi icons onto it.
  • Update the kobo screen with the new image.
  • Wait a while (5 seconds at the moment for testing, but will make it longer in the future - 5 min would probably be plenty).
  • Repeat indefinitely.
The source code is in my github repository.

The resulting display is pretty basic, but functional as shown in the picture.

Things to Do

There are a few improvements I would like to make to this:
  1. Make it less power intensive by switching off wifi when it is not needed (it can flatten its battery in about 12 hours so will need to be plugged into a mains adapter at the moment).
  2. Make it respond to the power switch - you can switch it off by holding the power switch across for about 15 seconds, but it does not shutdown nicely - no 'bye' display on the screen or anything like that - just freezes.
  3. Get it working as a usb mass storage device again - it does usb networking at the moment instead, so you have to use ftp to update the software or log in and use vi to edit the configuration files - not user friendly.
  4. Make it respond to the touch screen - I will need to interpret the data that appears in /dev/input for this.  The python library evdev should help with interpreting the data, but it uses native c code so I need a cross compiler environment for the kobo to use that, which I have not set up yet.  Might be as easy to code it myself as I will only be doing simple things.
  5. Get it to flash its LED to show that there are unread emails - might have to modify the hardware to add a bigger LED that faces the front rather than top too.
  6. Documentation - if anyone wants to get this working themselves, they will need to put some effort in, because the above is a long way off being a tutorial.   It should be possible to make a kobo firmware update file that would install it if people are interested in trying though.


Post a Comment