Some after-hour productivity with X1 – playing with andEngine to create Android game

I have X1 Carbon for a few months now.  While I use it here and there during work-hour, mostly doing web development, I also play with it after work.  My background is system-programming with C++ and some Java (I worked in financial information bus stuff) , so I miss them a bit, which is why I pick up developing Android game.

I use AndEngine, an excellent game engine that allows me to create two games in about month.  It is a word puzzle game.  There are more than a few word puzzle games already for Android, but I do my version anyway. The first game is called Word Drift.  It is a combination of classic game called 15-puzzle (the one that you have to move blocks of numbers until there are in order in a grid of 4×4) and a word search game.

The second one is based on the same idea, but it is less involving, simpler and I ended up like it more than the first one.  This is the one I’m posting the screen shot here.  It’s called The Wordest Puzzle.  Stupid name, I know 🙂


Basically, you have to move blocks of letter to form words.  The words must be at least 2-letter long, but longer words trigger combo and bombs.  You can keep the combo going by forming word with 3 letters or more.  You have about 12 seconds before the combo goes out, but if you submit word with 4 or more letters during that time, the combo timer is reset and you have another 12 seconds.  The longer the combo is activated, the more likely the bombs are dropped.

By the way, if the Android simulator takes lots of screen real estate.  It would be pain if not because the 1600×900 of the Carbon.  I guess my next notebook will be full HD.  My previous notebook lasted 8 years though, so that new notebook will probably bought in the next decade 🙂
Anyway, if you have Android phone, please give Wordest a try and any feedback will be very appreciated.


Linux on Samsung Series 9 UltraBook

When I decided I want a new notebook, Samsung Series 9 was one of three on my list (other two are X1 Carbon and ASUS Zenbook).  I ended up getting X1 Carbon, but Series 9 came close.  It is a bit cheaper ($1250 at Amazon currently), has longer batter life, and it looks curvier.

The reason I got X1 Carbon is that Lenovo notebooks for the most parts have good track record with Linux.  Also, while I used Thinkpad before (T41), I have never touched Samsung notebook.  I was not sure if I could put Linux on it.  Well, look like Samsung Series 9 runs Linux just fine.

Over at Jos’s website seeing him putting SUSE on his Series 9.  Pretty much everything works, with the exception of an ability to detect if the notebook is on battery and to detect if the lid is closed.  I think Jos will figure it out eventually.

fixing graphic glitch on crunchbang 11

I wrote in previous post that while crunchbang 11 test image works on Lenovo X1 carbon, there is a small graphic glitch on the panel.  This is what I’m talking about.

Basically the icons are not completely drawn and part of the background that is supposed to be transparent, is not.

I just found out that  this is the result of the interaction between tint2 (the panel program) and Compositor, the program that add shadow and other eye-candy on the desktop.  Disable compositor completely fix the problem, but I like to have it enabled.  So, to make them work together is simply to run tint2 first, wait a few seconds, and then run compositor.

In another word, in the autostart file (~/.config/openbox/autostart), change the group start section from

nitrogen --restore && \
cb-compositor --start && \
sleep 2s && \
tint2 \
) &

to look like this

nitrogen --restore && \
tint2 \
) &

then add this line after that

(sleep 5s && cb-compositor --start) &

You can combine them into one chained statement but these two lines work for me when I tried so I leave them just like that.

The result is much better.

X1 Carbon driver download page

The main reason I didn’t just wipe the recovery image from the hard drive was I don’t want to lose the drivers.  Those drivers, however, can be downloaded from Lenovo website.  Good thing they put them all in one page so no one has to search the site for them.

Lenovo X1 carbon vs. Samsung Series 9 vs. Asus Zenbook Prime


Three similarly spec’ed ultrabook comparison.   The prices were quite different at the time they were announced, but look like they all settle down at about $1250.  See spec comparison here



Install Linux on Lenovo X1 Carbon

After 7 years, my notebook is dying.  It’s time for a new one.  My requirement is simple.  High-resolution screen (anything higher than 1366×768 is OK) and light weight.

While researching, Lenovo released the new Thinkpad, X1 Carbon ultrabook.  I used to use Thinkpad T41 and really liked it.  This Thinkpad comes with 1600×900 screen and a SSD with Intel new Ivy Bridge CPU.  However,  Thinkpad notebooks are always on the expensive side, and this X1 Carbon is no difference.  However, with a 10% discount promotion I got by signup for a news letter, the price came down within my budget, so I pulled the trigger.

It took about a week for Lenovo to deliver my X1 Carbon.  Turning on the machine took about 30 seconds before the Windows login screen shows up, which is quite slow given it has SSD.  Turned out there were tons of pre-installed software.  The ThinkVantages, Lenovo Business software suit, shows itself proudly in the task bar, so I removed most of them.  Next, Norton Antivirus asked me to register to get a license that is valid for 30 lousy days. So Norton is gone. I download Microsoft Security Essential and that will stop Windows from asking me to install an anti-virus program.  After all those software removed, boot time  is down to about 15 seconds.

Reclaim the space

Lenovo put the recovery disk images on the SSD.  It sit on its own partition (drive D:)  that is about 13Gb.  This is on a SSD with only 128Gb.  Luckily, it comes with the program that will burn those images to DVD and let you claim back those space. I have an external DVD writer lying around so it was no problem.  If you don’t have one, I think the program lets you copy those images to USB harddrive too.

If you are going to burn it to the DVDs, you will need one DVD for Windows 7 images, and 4 other DVDs for the programs that Lenovo bundled with the machine.  I tried to make a second copy of the images, just in case,but the program wouldn’t let me.  It said I am only allowed to have one copy of those images. I guess Lenovo doesn’t know I know how to clone those DVDs without using their program 🙂

Anyway, once you burn those images, you can use the program to claim the disk space. The program is nice enough to merge the empty space to the existing partition.  Note that there is another 10Gb partition reserved for hibernation.


Windows 7 comes with a tool that lets you shrink the size of the partition. I was able to shrink Windows partition down to about 70Gb,  leaving about 40Gb empty space that I will install Linux on.

First stop, Ubuntu

TL;DR – Everything works.

I downloaded Ubuntu 12.04 64bit and put it in my external DVD drive.  X1 Carbon booted from the DVD drive without any problem.  The bios looks for external drive for booting by default.

Installing Ubuntu went very well. At one point, it even turned on the webcam and gave me a choice if I want to take a selt-portrate and use it on the login screen.  I refused and choose the picture of a duck instead.

Ubuntu is a mature Linux distro, I did not expect any problem, and there there was no problems. Every just work, including multi-touch gesture.

However, Ubuntu is heavyweight, do-it-all distro. Running Unity session with one terminal opened used more than one Gb of memory.  X1 Carbon only has 4Gb of memory, which, by the way, more than enough for what I do, but using more than 25% of total memory doing nothing is a bit too much.

So I decided to install openbox on Ubuntu. Following the document on Ubuntu website, I typed away this command:

sudo apt-get install openbox obconf

and just like that, openbox is running on my X1 Carbon. The memory usage is down to about 650Mb, which is a great improvement, but if I’m going to use light weight WM, I might as well go lightweight for the whole system.

Arch Linux?

I considered Arch.  Thanks to Ubuntu, I know the hardware works, so  if I give it some time I would be running an amazing Arch machine.  However, I wanted something quicker and easier to install that lets me get back to work quick. So, no Arch this time.


I ended up installing CrunchBang, a small, lightweight Linux distribution based on Debian. At one time I had it installed on my previous notebook  and I was quite impressed with its small memory footprint and speed. Installing CrunchBang on X1 Carbon turned out to be a little pain though.

CrunchBang Linux, or #! for short, currently at 10th iteration, comes with two stable versions.  The standard one and the backported one. Both have 32 and 64bit releases.

Problem with #! 10 non-backport release

I decided to have something stable (this is going to be work machine after all), so I downloaded the 64bit non-backported. Installing went OK but I found that the wireless network didn’t work. Also, the synaptics touchpad driver didn’t get loaded for some reason, so multi-fingure geature wouldn’t work. I could have been able to fixed it by download the right drivers, but X1 Carbon only have Wifi.  Without Wifi connection, I would need to download those drivers, copy them to X1 Carbon, and try them out.  If my Linux experience teaches me anything, I would know that it won’t work the first time. That means I have to repeat those download-and-copy thing several times so I kindda gave up and download the backport release.

Problem with #! 10 backport release

Wifi and touchpad driver worked with backport release, but the screen was not. It looks like the horizontal sync was not

correctly setup. At first I though it was X that messed up so I looked for X config file to fix it. The last time I had to manually fix the X config file was when every was happily using XFree86. I couldn’t even figure out where all the config files for Xorg went. Tuened out they are located at /usr/share/X11, but there is no xorg.conf, which I later learned that Xorg automatically detect the setting so no config file is needed. If xorg.conf exists at /etc/X11, it will be used though.

So, I start editing xorg.conf. I run X -configure to create the in my current directory. I copied it to /etc/X11 and rename it and start editing it. However, it didn’t make any different no matter what I tried.  Fustrated, I removed all X stuff from the X1 Carbon, hoping reinstall them might magically fix the problem. Once X is gone, I reboot  and the machine entered framebuffer console. To my surprise, the framebuffer console has the same problem. It is now clear that it is not X, but it’s the display driver (i915, by the way) that has major issue.

Success with #! 11 testing image

Look like #! is no go. However, before going back to Ubuntu, I decided to give #! another chance. There is a test image of the next release (CrunchBang 11 Waldorf) available. I downloaded it and try it, and it works!.  Interestingly, the installer does not detect Windows 7 partition, but when I reboot the machine after installed, Windows 7 is one of the option in there.

There are also small graphic glitches on the top panel where some icons are not completely drawn. but they don’t bother me.  More importantly,  seeing that it uses only about 300Mb convinced me that at lease I should try living with this unstable release for a while. It might work out, who knows? 🙂

Tuning #! for X1 carbon

I was worried about heat and fan noise, but it turned out to be no issue. The heat and noise levels are not different from when it is running Windows 7.

I did added trim support to the SSD. To do so, I added ‘discard’ to fstab

UUID=bfebbf2f-7b62-4415-a232-b83fc276f362 /        ext4   discard,errors=remount-ro 0 1

By the way, when assigning partitions for Linux, I only have two partitions, one big “/” that is ext4, and a 1Gb swap that  I don’t really expect to use (4gig should be enough for me). Everything I do on this machine will be on SVN server, which in turn backup’ed to Amazon S3. For this reason, I’m not too worry about partitioning too much.

Note that people with Intel graphice cards that use i915 driver can turn on power-saving mode by adding “i915.i915_enable_rc6=1” kernel module parameter when booting the machine.  However, rc6 is on by default for Ivy Bridge CPU like the one in this X1 Carbon.

By the way, I get between 4 and 5 hours of usage off a fully charged battery, mostly depend on how bright my screen is. It is comparable to what I get when running Windows.  If the screen is on full brightness, then it only lasts about 3.5 hours.

Multi-touch gesture

Next, I customized the multi-touch gesture.  I wanted it to behave like it does on Windows. That is, a tab for left click, two-finger click for right click, 3-finger click for middle click, and, of course, two-finger scroll.

To do that, I open Openbox autostart script, located at ~/.config/openbox/autostart, and add these lines to synaptics section.

synclient VertEdgeScroll=0 &
synclient TapButton1=1 &
synclient ClickFinger2=3 &
synclient ClickFinger3=2 &
synclient PalmDetect=true &
synclient ClickPad=true &

So far multi-touch gesture has been awesome, but there are a lot more customize options that I have not tried.  See ‘man synaptics’ for all the options.  I am particularly interested in what the “circular scroll” is, but I am too lazy to find out.

Adding second keyboard layout

When I installed #! on my previous notebook, it somehow figured out my second language automatically (which is Thai, by the way).  However, I had no such luck this time with X1 Carbon.  This is an easy fix though.  Adding these two lines to autostart script, and I can switch keyboard layout with Alt-Shift, which is the same key combination used in Windows 7.

(sleep 2s && setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,th) &
(sleep 5s && fbxkb) &

The first line add second layout to the keyboard, the second line calls the small applet that will be running on the top panel, indicating the current keyboard layout.

Because I choose to use Alt-Shift to switch keyboard layout,  pressing a key to trigger emacs text replacement mode becomes a bit harder (since emacs uses similar key combination for this purpose : Alt-Shift-%, or for regex replacement, Ctrl-Alt-Shift-%), so emacs fan should take note.

That’s it for now

This is all I have done so far, and I’m quite happy with it. X1 Carbon is an expensive notebook, even with the discount, and the screen can use some improvement, but overall it is a solid and fast machine. I also like that people don’t look at me using it like when I look at people using MacBook Air 🙂

Also, with #!, everything happens instantly. Ubuntu was fast too, but you can feel small latency on everything you do GUI-ly. That feeling is gone with #! (thanks you openbox I guess). If you are still considering X1 Carbon, I say go ahead and get one, and then give #! a try.

(note: I have not tested the fingerprint reader and display port  as I do not plan to use them at this point.  Thinkpad fingerprint readers are known to work under Linux and I don’t see why the display port won’t work)