Sunday, May 26, 2013

Adding Linux to My Samsung Chromebook

Why I Need Linux

I described my reasons for needing some Linux applications in previous blog posts. To summarize briefly:
  • I want to use a local mail client instead of using Gmail or some other web-based mail client
  • I want to continue using GnuCash.
  • I want to continue using GIMP for image processing
  • I want to continue using LibreOffice for document generation
  • I want to be able to access my scanner
  • I need native code to access my Garmin ANT+ USB stick to download date from my Garmin GPS watch to my computer.
As I also explained previously, part of my concern is the security and privacy of my data if I use Cloud storage and/or web-based applications.  Were it not for those concerns, the only thing I really couldn't do is use my Garmin ANT+ USB stick. For the scanner, theoretically I could scan to a USB flash drive and transfer images that way. 

I described in this blog post my decision to use crouton to provide me with an Ubuntu environment to run alongside the Chrome OS environment.

Installing Crouton

I described near the bottom of this blog post the steps I would take to install crouton with Enlightenment (e17) as my desktop environment.  I followed the steps as described (which took approximately 30 minutes), and after the system rebooted I did the following:
  • I used Ctrl-Alt-T to open a terminal (crosh).
  • Into the terminal window I typed "shell" (without the quotes) and hit enter
  • I typed "sudo starte17" and hit enter
  • Enlightenment started (quickly) and I was in!
As advertised, I could use Ctrl-Alt-Shift-leftarrow to get back to the regular Chrome OS, and Ctrl-Alt-Shift-rightarrow to get back to the Linux environment. (The left and right arrow keys are on the top row of the keyboard, next to the ESC key.) The switching was essentially instantaneous.

Next Steps

The crouton installation process installed a basic set of packages (applications, utilities, libraries, etc.) plus the enlightenment desktop environment, since that is the one I chose.  Obviously though there were additional packages I wanted to add. To make that easier, I first installed synaptic:

sudo apt-get install synaptic

I have used synaptic for many years. In recent years, Ubuntu has not installed synaptic by default, but instead installed the Ubuntu Software Center.  I read a comment recently where someone said that the Ubuntu software-center could be installed in the crouton environment as well, but as of this writing I have not tried it.  

With synaptic installed, I could now enter synaptic to search for and install additional packages. Using synaptic (as well as the command line apt-get tool), dependencies would be found and downloaded as well.   To my surprise, when I tried to execute "sudo synaptic" the command was not found. I searched around and found that the executable was actually" synaptic-pkexec". Entering 

sudo synaptic-pkexec 

worked. Of course it asked me for my password. I updated the sudoers file so that I would be allowed to execute it without entering the password (if I am logged in). This allowed me to invoke synaptic from the menu as well. Note that with recent versions of Ubuntu (like 13.04 which I installed) you can create sudoers entries in new files (which get included) in the /etc/sudoers.d directory rather than editing the sudoers file directly.  Of course, you still need to know the correct format.

Using Enlightenment

Given that I had previously mainly been using GNOME or KDE, Enlightenment (e17) was new to me.  I was a little disappointed to learn that the version installed was not the 0.17.3 latest stable version. I attempted to use an enlightenment PPA to add the latest version, but the PPA did not include ARM builds.  I may consider trying to build the e17 and e17-data packages myself in the future if newer ARM versions do not become available.  Here is a screenshot of my Enlightenment desktop:


Adding Additional Applications

Mail Client (Sylpheed)

As discussed in a previous blog post, I had chosen sylpheed as my email client. Within synaptic, all I had to do was search for synaptic and then install it.  I did this and I was able to start it immediately.  The next step was a little more involved though. I was interested in the HtmlView plug-in for sylpheed so I could have HTML within email rendered if desired.  Unfortunately, the HtmlView plug-in for sylpheed was not in the Ubuntu repository.  This is understandable, since the plug-in is developed by a single individual who may not have the time and/or desire to build packages for various types of distributions and architectures. The site for it though provided steps for downloading and building it.  If you have not ever done anything like this it might be a little daunting, but I have.

However, initially I tried to build it on my Thinkpad laptop, before receiving the Chromebook. The problem with that is that the Thinkpad and the Chromebook use different architectures. The Thinkpad is Intel (x86_64) and the Chromebook is ARM (armhf).  So in trying to build the plug-in for Chromebook on my Thinkpad, I was cross-compiling.  Typical packages for building an application are really written assuming you are building on the same platform you are going to be running the program on.  I explained in this blog post my attempt to cross-compile the HtmlView plug-in. Prior to my Chomebook arriving, I did spend a fair amount of time trying to update the make files to use the Sourcery CodeBench Lite Edition to cross-compile the code. While I was able to get it to compile,  I was not able to get the code to link properly.  I abandoned the effort once I received the Chromebook and decided to build on the Chromebook instead. I may go back and try cross-compiling again some time in the future.

In order to build the package on the Chromebook I had to install additional packages. This is hopefully a complete list: build-essential, autogen, git, subversion, libglib2.0-dev, automake, libtool, libgtk2.0-dev, libgpgme11-dev, flex, bison.  Once I got all the correct packages installed, following the documented steps resulted in a successful compilation. Of course, as usual, I had to start over the make steps (not the download steps) each time I discovered a missing package.

After building the HtmlView plug-in successfully (which included copying the plug-in to the correct directory via the "make copy" step), I restarted sylpheed. At first I did not see an HTML tab show up for emails containing HTML. I read the README.md file  that came with the source and saw that I had to go to Configuration->Common Preferences, then click on the Display tab, and then the Attachment sub-tab and check the "Toggle attachment list view with tab" checkbox.  After doing this I got an HTML tab, as you can see in this screenshot (Text tab selected):


When I click on the HTML tab I get the HTML rendering for the message, as shown below:


One thing to be aware of is that if you are in the HTML tab and click on a link in the message, it will render the HTML for that link directly in the message window (in sylpheed) rather than opening a browser. Once I did that I did not see a way to get back to the previous HTML. Right clicking did bring up a menu, but the "Back" button was grayed out. So at this point if I want to click on a link, I will probably go back to the the Text tab first and click on it there. When I click on a link from the Text tab, it opens the Chrome browser. I didn't install that so I assume either crouton did or one of the other packages I downloaded had a dependency on it. 

Note that there are some HtmlView configuration options under Tools->HtmlView. One of these is a checkbox which causes the HTML tab to be rendered automatically. I chose not to do this, partially because of the linking issue mentioned above.

On my Thinkpad, I was able to export my mail files (in Mbox file format) in Thunderbird using the ImportExportTools plug-in I had previously installed. Within sylpheed I could select the file to import from and specify which folder to import those messages into.  I was able to export my address books in LDIF format and import them into sylpheed. Note however that in sylpheed you just get the name and email normally. Any additional information (like phone number) shows up in the Remarks field.

In using sylpheed for a few days, I have found it to be pretty fully featured.  It doesn't have extras, like a calendar, but for email it has a lot, including support for IMAP, encryption (GnuPG), IPV6, and filtering.

By the way, sylpheed was written by Hiroyuki Yamamoto and, according to the FAQ, "sylpheed" means light weight (like air).  This supposedly explains why it is so fast.

At his point I am pretty satisfied with sylpheed.  Running it in the crouton chroot environment, I have a couple of minor concerns:
  • If I click on a link, it launches the browser in the chroot environment. I have Chrome running in the Chrome OS environment, so I would rather see my web stuff there.
  • When I am in the Chrome OS environment, I have no notification that I have new email unless I switch over to the chroot environment and check the sylpheed email client.
At this point these are clearly minor concerns.  However, I am considering if I might be able to remedy these issues with some coding.  From perusing some of the Chrome development documentation, it appears that you can send some messages over a socket. There are some sample applications that demonstrate this.  Thus I am considering doing the following:
  1. Write a simple application to run with the Linux chroot which opens a socket on localhost (127.0.1.1) and sends a message indicating a URL to render in the Chrome browser, or some information about message(s) received.
  2. Write a Chrome app or extension to read from the socket and get the information. For a URL, it would open a tab for that URL.  For notifications, it would use some sort of notification API (I assume there is one) to display messages.
On the Linux side, invoking the tool with the URL is simple, since the sylpheed has a configuration option to control what to do with URLs. I could tell it to invoke my new tool, passing the URL.  For the notification part, I might have to write a sylpheed plug-in.

For the notifications, I would only want to send the notifications to the Chrome OS environment if I was viewing that environment, but not if I was in the Linux chroot environment. Whether or not I can determine that will take further investigation.

Additionally, when running in the Linux chroot environment and sending over a URL to open, it would be nice if there was a programmatic way to switch to the Chrome OS environment (rather than Ctrl-Alt-Shift-leftarrow).  I don't know if that is possible.

In terms of notifications, after thinking about it for a while, I realized that I theoretically would be working mainly in the Chrome OS environment. Therefore it would be nice to know in that environment whether I had email to check. If I did, I could then go over to the email client and read the email. In looking for something along those lines, I found X-notifier. There is a version in the Chrome web app store. It supports multiple email accounts, plus there are available scripts for various email providers (like Comcast in my case). With X-notifier you can be notified when you have e-mail. In addition, via a click, it can take you to the web email site to actually read your email.

Support for Garmin ANT+ USB Stick

For my Thinkpad, it took some investigation and attempts at various different tools before I was able to come up with a solution that would allow me to both download data from my Garmin GPS watch and process it in a display tool.  The second part was not an absolute necessity, as there is a Garmin website that you can upload the data to if you prefer.

There is more than one Linux tool for downloading data from the watch. The only one I was able to get to work was python-ant-downloader.  I was able to follow the instructions and install this program on the Chromebook.  Next I needed to add a file containing information describing the USB stick in /etc/udev/rules.d to that Linux would recognize and let me access the device. I created a 52garmin.rules (you typically use number prefixes to control the order your rule will be processed relative to other rules) containing the following:

ATTRS{idVendor}==”0fcf”, ATTRS{idProduct}==”1008″, MODE=”666″

Note that you get the vendor and product IDs by plugging in the device and using the lsusb command to get the information. Note also that you need to use sudo to copy or add files under /etc/

In order to execute the program, I needed to run it with sudo. So I created a script, called garmin_download.sh containing the following:

#!/bin/bash
sudo ant-downloader

Note that although the package is named python-ant-downloader, the actual executable program is ant-downloader.

In order to execute the program without having to enter my password, I added a file named ant-downloader in /etc/sudoers.d containing the following:

%sudo ALL=(ALL)NOPASSWD:/usr/local/bin/ant-downloader

This specifies that anyone in the sudo group can access the tool without password. In my case, my user ID is in the sudo group.  There are other ways to do this, which you can see by consulting sudoers documentation.

Previously, in investigating options for my Thinknpad, there was an additional neat tool I found. It is called cuttlefish.  It allowed me to set things up so that when I plugged by ANT+ USB stick into the USB slot on my Thinkpad the garmin_download.sh script would automatically run.  Although having the tool invoked automatically was just a convenience, it was nice to have. Unfortunately, I was unable to install cuttlefish in my crouton environment. I suspect the reason is that cuttlefish was written assuming the Unity desktop environment. Since I was using enlightenment instead, it would not install. I tried working around it briefly, but then gave up since it is not critical. I may investigate it again sometime in the future.






No comments:

Post a Comment