Fit for Purpose: Linux Mint Debian Edition on Sony Vaio Flip 13

Update: Since writing this, I have two things to add. Firstly, Linux Mint are terrible custodians of a distro and should no longer be trusted; they end-of-life’d LMDE mid-cycle with no upgrade/escape path to Debian, which is simply sloppy, and their packaging system for stock Linux Mint has come under scrutiny for being amateur-hour BS. Secondly, all of the below is now outdated, because Ubuntu works perfectly out of the box on this laptop, without any further hax or modifications. Enjoy!

Tired of having to carefully hold the case corner together when opening my old Asus laptop lid, and of the lacklustre performance on fairly simple tasks, I have been looking at getting a new laptop for some time now. When the opportunity arose to get a pretty high-end laptop at a several-hundred-euro discount (store display model!), I snapped it up, after testing quickly that it worked with LMDE (Linux Mint Debian Edition, my preferred OS) - I carry a liveUSB around for this reason!

The laptop in question is the Sony Vaio Flip, apparently one of the last Vaios ever made before Sony elected to leave the computer market. Which is a pity, because as last hurrahs go, this is a very nice laptop.

So, before going further, I’m not just writing this as a review. I heartily endorse this laptop to anyone who can find and afford one; as a Linux laptop it’s excellent and I’m still enjoying basic use. I’m writing this so that if people do go out and buy one on my word, they’ll have a reference document for setting up the juicy stuff; ironing out minor bugs, setting up multitouch, configuring features. All the stuff it comes preconfigured for on Windows, but why are you settling for Windows?

I won’t re-hash marketing materials available on a quick search, but the gist is that it’s a convertible that flips the screen down over the keyboard when in tablet mode, unlike the more popular but less elegant flip-over-back design popularised by the Lenovo Yoga series. It has a face-facing webcam and a forward (when holding it in tablet mode) camera also. The touchscreen is also a digitiser and it comes with a digi-pen, although I wasn’t told any of this when buying it! I also wasn’t told that it came with a tiny charger-mounting wifi router, designed for the sole purpose of enabling the use of ethernet cable-only internet in hotels etcetera. More on this later. Inside, it’s a dual-core Intel with dedicated Intel graphics, 128GB SSD, 8GB RAM, 2x USB3, HDMI, SD card slot, and combination audio. All the good stuff, none of the cruft.

So, here it is, running LMDE:

LMDE on Sony Vaio Flip 13
With a keen little portable speaker I picked up for cheaps, too.

And here it is in tablet mode, in case you didn’t believe me:

In case you didn't believe me.
As if anyone would doubt my word..

So, upon testing in the shop, more or less all the critical stuff worked immediately: Wifi, Sound, Microphone, both cameras, screen, sleep, resume (though..), touchscreen, power/battery. I’m pretty happy if all that stuff is working out of the box, and the rest is configuration.

It’s rare that things go so smoothly on testing, so I snapped it up for a hefty price despite significant discount, but I expect this metal-cased thing to last me for a good few years so compared to my cheap plastic Asus I’m considering the amortised cost very reasonable.

Now, on to the stuff I discovered upon further testing.

Booting into Linux

Simple! Shut down the computer, and just press the “ASSIST” button at the top-right of the keyboard. It’ll boot into a touch-aware BIOS with a conspicuous icon to boot from “recovery media”…but first you’ll have to disable UEFI boot mode in BIOS settings unless you’ve created a UEFI boot USB. I didn’t; just go to BIOS settings, go to the boot pane, and change the UEFI boot option to “Legacy”, then return to the main BIOS boot screen and tap “boot from recovery media” to boot from the USB.

Suggested Software

After installing the usual stuff (fresh python3.4 from source, pip-installed favourite tools and libraries, mail accounts, https-everywhere, disconnect, adblock plus, greasemonkey), there are a few things that particularly suit the touchscreen.

One obvious requirement is a decent keyboard, and I recommend the Florence virtual keyboard. It has a few odd bugs, and it’s a little unstable. I find that if it’s enabled, then the “repeat” feature of the normal keyboard stops after about three repeats, so navigating through text becomes a pain; just close Florence when in laptop orientation. I also find that when something like Firefox’s URL suggestions dropdown appears, it seizes focus from Florence, and I have to tap on florence to get focus again and resume typing. Then, when the dropdown stops suggesting things, florence works normally.

IMG_20141021_114828

I would contemplate a script that tries to change Firefox settings on the fly when it detects a change of orientation, but that sounds like too much work. The likely fastest fix is just to turn off search suggestions until needed, but I find it too valuable, and I can endure a little discomfort for that value.

Next, given that the computer comes with a digitiser and drawing pen, is a drawing application. GIMP is an all-round fantastic image editing suite, but for natural-feeling and pretty “painting” or “freehand” drawing, install “MyPaint”. I left my three-year-old daughter playing with this and she quickly figured out the colour swatch and how to change pen types, which says a lot about the design. Pressure-sensitivity worked for me right away, no configuration needed.

IMG_20141021_114543

Keyboard/Mouse Failure on Resume from Sleep

Update: This is no longer relevant when using Ubuntu. Ignore the below, everything about this Laptop works perfectly under Ubuntu Linux. :)

One bug that wasn’t apparent in the shop on LiveUSB mode, because no login screen appears in this case, is that on resuming from sleep the mouse and keyboard (but not the touchscreen) are disabled.

Fixing this is straightforward if you simply change your boot options so that Linux will reset the keyboard and mouse after resuming. The specific options you’ll need are ‘atkbd.reset i8042.reset’; add those two settings directly after the Linux boot line, and you’re set.

However, on LMDE and modern Debians, the boot options are generated by a somewhat arcane configuration file, so if you just change the /boot/grub/grub.cfg file as suggested by some, it’ll be overwritten at some stage in the future by an update and you’ll be back to square one. You need, rather, to edit the config files.

Trying to make this gentle for the non-technical user, I suggest the following:

  1. From the main mint menu, select Terminal
  2. In terminal, type gksu pluma /etc/defaults/grub, to open the Pluma text editor using super-user (gksu) and edit the /etc/defaults/grub file, from which new configs will be drawn when grub updates.
  3. The line beginning with _GRUB_CMDLINE_LINUXDEFAULT is the string of options added to Linux’s boot line, so add your options here. When I added the options to mine, the line read: _GRUB_CMDLINE_LINUXDEFAULT=“quiet splash atkbd.reset i8042.reset” (remember to leave the quotation marks around the options intact),
  4. Optional: While you’re in here, if you’d like to stop the boot screen from displaying at all during boot-up and shave 5 seconds off the boot process, change the option _GRUB_TIMEOUT _to 0 (zero).
  5. Click save, then close. That’s the default config done, but your current config still has the old options, so open that next: gksu pluma /boot/grub/grub.cfg
  6. This one is uglier and harder; you’re looking for the first menuentry definition, so use search (control-f) to seek “menuentry”. In the block of indented code that immediately follows, one line will begin with linux, and read something like: linux    /boot/vmlinuz-3.11-2-amd64 root=UUID=(junk) ro  quiet splash
  7. Your “root=UUID=” will be unique, so ignore it. You want to add the new options after the “ro quiet splash“: My boot-line now reads: “linux    /boot/vmlinuz-3.11-2-amd64 root=UUID=(junk) ro  quiet splash i8042.reset atkbd.reset”
  8. Save and reboot.

That’s it: after the above, your keyboard and mouse should work after resume without further issue.

Multitouch Touchpad

Update: This is no longer relevant when using Ubuntu. Ignore the below, everything about this Laptop works perfectly under Ubuntu Linux. :)

The touchscreen works out of the box, as does the pen digitiser; brilliant! Thanks Linux. However, the touchpad is not multi-touch enabled by default, and there’s a small bit of witchcraft necessary to get it going.

So, the bug which prevents it from working, which is apparently a case of “manufacturer is incompetent, keeps changing hardware interfaces, won’t release source code even though they are a hardware company” (also true of many major manufacturers, sadly), is here.

The fix, thanks to a contributor to that thread, is now pretty straightforward:

  1. Download a patch, which I’m hosting here on this blog to avoid broken links, but can also be had if you read through the above bug. Save it with the filename it’s given, because the below commands use that filename.
  2. From the mint menu, select Terminal.
  3. In terminal, navigate to where the file was saved. This is probably the Downloads folder, so use cd Downloads (if you’re a terminal n00b, ‘cd’ means ‘change directory’).
  4. Type the following commands; you’ll be asked for your user password, and you may be scolded about responsibly using “root privileges”. The first command should do nothing on a Debian system, but just in case any Ubuntu/Linux Mint users are following it may help avoid pain.
    1. sudo apt-get install build-essential
    2. sudo dkms ldtarball psmouse-elantech-x551c.tar.gz
    3. sudo dkms install -m psmouse -v elantech-x551c
    4. sudo rmmod psmouse
    5. sudo modprobe psmouse
  5. The above should immediately add support for multitouch in the “mouse” settings application, found via Mint Menu->All Applications->Preferences->Mouse; you ought to see a new tab for the touchpad with the usual options. If this doesn’t appear right away, try rebooting and look again. Normal touchpad multi-touch can be enabled here; two-finger scroll, etcetera.

Multitouch Touchscreen

Update: Ubuntu’s “Unity” interface now comes with a bunch of nice gestures built-in, and the GNOME3 desktop (which I prefer to use) likewise comes well-configured for touch. Touchegg setup is sadly more complex because of conflicts with the builtin desktops, and isn’t worth the pain anymore. The only serious need is for browsers, and in Firefox I recommend simply installing a touch/gesture addon.

This one is much easier, don’t worry! The touchscreen works perfectly, but to get multitouch gestures you’ll just need to run an application called “Touchégg” as a background process. You’ll also need some configuration options but I have a sample, adapted from an Ubuntu forum user’s, which works great.

If you’re using Ubuntu or “stock” Linux Mint, you should be able to install from the Terminal using just sudo apt-get install touchegg, so try that first.

If you’re using Debian, or if the above fails, you can compile a fresh version from source, following the instructions on the Touchegg wiki. Just remember to use cd to enter the uncompressed Touchegg source code folder before doing step 3.

Once you have touchegg installed, you’ll need a configuration file that makes it work with the touchscreen. Here’s mine. You need to save that file, then open Terminal, cd into the Downloads folder, then move it to where it belongs using_ tar -xaf touchegg.conf.tar.gz; mkdir ~/.config/touchegg; mv touchegg.conf ~/.config/touchegg _-Once you’ve done this, you can start or re-start touchegg from the same terminal window by typing, simply, _pkill touchegg; _touchegg, and test the multi-touch commands defined in that configuration file on your touchscreen.

If all works correctly, you’ll want to have this start with your computer, and to stay alive as long as you’re using your computer. I found that touchegg is a little unstable, though, and sometimes crashes quietly, reverting you to chump-mode. To fix this, use a quick python script which will launch touchegg for you and reset it every time it crashes. Save this python script (compressed so wordpress will accept it) and use the terminal to decompress it and move it somewhere permanent: tar -xaf keeptouching.py.tar.gz; mv keeptouching.py ~/.config/touchegg/

Now go to the Mint Menu->All Applications->Preferences->Startup Applications and click “Add”. In the dialog, give a name and description you like, then for “command” type _python3 /home//.config/touch_egg/keeptouching.py

Try restarting your computer; touchegg should be running. If it crashes, it’ll quietly be resurrected by the python script. It’s unlikely that Python will crash, but if touchegg quits normally somehow then Python will exit also.

You can figure out by reading the touchegg.conf file how to define new commands or edit existing ones; I added a three-finger-tap to Firefox to launch a new tab, and I added a general purpose four-finger-tap to close windows using control-W. The five-finger-tap to close applications is pretty consistent with this. I also overrode the double-finger left/right swipe in Firefox so that instead of moving the window it moves between tabs (as if by swiping aside the current tab).

Rotation

This is a developing area. I have a script kindly shared here which will, when run, rotate the screen and cycle through each 90-degree stage of rotation, which is helpful when you want to us the computer in A4 orientation.

However, there is as-yet no defined system to read the accelerometer and auto-rotate, although the drivers to access the device are available. If someone writes the code and presents an interface others can use safely, then the above script could be easily adapted into a listening server that rotates according to device orientation.

As a small and totally fixable gripe, the screen seems to have a separate digitiser to the finger-touch sensor, and this isn’t rotated correctly, so the pen doesn’t work in alternate rotations. However, I suspect this is a matter of merely adding a few lines to the script to rotate the digitiser input, too, and may set about doing that soon so I can draw more easily in A4 mode.

Also, as an improvement, I’m planning to break this script into four icons on my desktop, each an arrow pointing in a different direction, which would let me skip the “cycle through rotations” business and get straight to poking the direction I want to assume. At least, until the accelerometer is set up correctly..

Router Hax

Another nice feature of this laptop was that it came with a mini wifi router that clicks directly onto the charger and shares whatever’s plugged into its ethernet port over wifi. It’s a nifty hack to get around the fact that there’s no ethernet on the laptop but sometimes only ethernet internet is available (many hotels, for example).

IMG_20141021_114909

Now, an ethernet adaptor would have been more practical, but this does let you tether more than one device, and it’s pretty cool, so I’ll pass on criticism. But I see wasted potential, here! Wouldn’t it be nice if that minirouter I can tote everywhere, which will auto-launch whenever I plug in the laptop, could be doing something useful like broadcasting a piratebox?

IMG_20141021_114733

Alas, the chipset in the device was initially unknown for certain. Kudos to Sony et al, however, that they used GPL licensed code and dutifully followed the terms of the GPL to release the code of the router’s firmware. I could probably work with this and hack something together if I had time, but I don’t. I wanted to know whether I could install OpenWRT on this thing as things stand, and use OpenWRT to install the necessary bits for PirateBox or whatever.

To answer this, I’d need the chipset, so I cracked mine open. The teardown is now posted to WikiDevi which seems to be the go-to for wifi hardware hackers. I put it back together and it still works. The answer I got wasn’t that useful, though; the chipset is a System-on-Chip (SoC) from Realtek which has, at best, preliminary support for OpenWRT etcetera. The better known model, RTL8196C, has received at least some hacking, but the RTL8196EU in the Sony router is virtually undocumented so far.

It’s possible I could just burn the bleeding-edge latest OpenWRT onto the device and have it work right away, but I’m not willing to risk bricking it and having to muck around with serial interfaces to get it back to normal. It’s also probable that if I mucked around with the source code provided by Sony I could get it to build, and burn in a few extra treats besides, but that’s a lot of time spent at a time when I have very little to spend.

So, I will just watch this space and hope that the RTL8196EU chipset gets some more love from the OpenWRT hacker community over the next few months; hopefully I can just install a stock version someone else has built and tested and get rolling with my little mobile digital-public-library mounted on a charger!

Summary

So, that’s it. Aside from accelerometer, everything is working perfectly, and I’m really enjoying this laptop. I find it very natural to use the touchscreen for many tasks alternately with the mouse and keyboard, quite unlike the argh-argh-burn-it pain of Windows 8 when I have been forced to endure it.

I’m tempted to install Gnome 3 or Unity alongside the desktop system I’m using, MATE, to finally try the so-called “built for touchscreen” interfaces I’ve previously only used with a keyboard/mouse. But honestly, after bumping up the size of the taskbar very slightly, the touchscreen on this laptop is precise enough for comfortable use on a non-dedicated interface, and the multitouch gestures defined by others and adapted for my needs more than make up the difference. Instead of poking carefully for “minimise” I use a three-finger-swipe. Instead of poking carefully for full-screen or close, I have the three-up-swipe or the five-finger-tap. Most of the things that are hard to touch correctly are easy to gesture, and vice versa.

My only general gripe is that I haven’t yet got the on-screen keyboard on the login-screen, so popping up the lid to type in my password is a tiny pain. I’ll get there eventually.

Again; if you’re looking for a laptop and love or want to try Linux, this model or range, the Sony Vaio Fit convertible, is fantastic. Very worth the price, feels robust and long-lived, and performs really well out of the box. After a little configuration as above, it’s easily the best laptop I’ve owned or used so far. A pity, then, that Sony are no longer making them! Get yours quickly. :)