Monthly Archive: December 2010

Bash Script to Install Ubuntu to CR-48 through USB easier (Updated)

Update (01/18/2011): Thanks to flyboy415’s comment below, it inspires me to add an optional parameter to the script that allows you to customize the path of your USB drive. You probably read my another post shows you how to mount the USB drive manually in Chrome OS. Now you can run this script with that directory that you created:

I spent last several days writing and testing the script which could help some of you installing Ubuntu onto CR-48 using USB drive a little easier.

This script is inspired by Jay’s script over at It’s also based on the steps over at the Chromium projects website. However, it uses your custom generated rootfs.bin in the USB drive instead of downloading the pre-made image.

Below is the entire script. You can either copy it directly to gEdit and save as .sh file or download the same script at github.

The Code

Few warnings before running this script

You need to running the script under bash instead of sh, for example

where ubuntu is the name of your script.

If you use sh instead, you won’t see the error messages produced on the screen and might need the recovery image to restore Chrome OS as stated in the script above.

The and files can be downloaded here which are provided by You might not have these two files during the chroot installation if you chose to get minilayout instead of the full layout of Chromium OS source code.

Other requirements, such as login as root, will be provided as you execute through the script.

Issues while running the script

If you have any issues while running this script, feel free to leave a comment or create an issue over at github.

Download WordPress and Other files Directly to your Server with PHP copy



When I tried to get the development environment working with Chrome OS (CR-48), I thought since Chrome OS is primary working for the cloud, why am I downloading, editing, and testing the website files locally? I found out that my hosting provider, iPage, offers a file manager and a basic text editor to manage and edit my PHP files, and since I use gEdit as my main code editor, I’m pretty comfortable with the text editor.

Basic code editor

The basic code editor available in the control panel

I shortly found some useful file operation functions on the official PHP document, one of them is copy. According to its documentation, the source and destination can both be URLs since 4.3.0. This means that I can download the code from another website directly to my server using the server resources. I wrote a test page to test this function and it worked without problem.

The Code

Note that I’m just starting to learn HTML5, so I can’t guarantee the above syntax is correct.


If you have any questions regarding this script, leave a comment below.

A Small Fancybox Tip – Show scrollbar when viewing Large Images


I use Fancybox jQuery plugin to view large/original size of images. However, its default settings don’t setup to view the large size images. It auto resizes based on the browser window size instead. According to the documentation, the options “autoScale” and “scrolling” disables the automatic scaling and enables the scrollbar to be visible respectively. However, I couldn’t figure out the scrolling option since the horizontal scrollbar is missing when viewing a large image that is bigger than the browser width. After looked into the code generated by Fancybox, I noticed that the scrolling option is applied to other than the body element, which is what I want the scrollbars to be at (edges of the browser window). So I used onStart option to write a callback function that set the overflow property for the body element to be visible.

The Code

Below is the difference between use the scrolling option and use the onStart callback function:


Scrolling Option

onStart callback function

onStart Callback Function



All of the above options are explained in the Fancybox document page. If you still have questions, feel free to ask them below.

More Storage Space for Ubuntu on Chromebook

Most of you download files within Ubuntu on the Chromebook with very limited hard drive space. What you may not know is that there are unmounted partitions listed above the bookmarks section in the file manager, especially the largest partition.

The process for acquiring additional storage space for use within Ubuntu is simple – just click the disk labeled largest GB File System” to mount it (make sure to replace largest with whatever the largest partition Ubuntu has detected), and then navigate to /home/chronos which is your home directory inside Chrome OS. Inside this folder, you can do the normal file operations like in your Ubuntu home folder. This will gives you additional gigabytes of hard drive space to save your documents.

Note that you cannot edit the files outside the chronos home folder. Only the “largest GB File System”, and C-OEM partition, which only has very small amount of free space available, can be accessed by Ubuntu, rest of the partitions (two C-ROOT and other partitions) cannot be accessed within Ubuntu.

If you have any issues on getting additional storage space, feel free to leave a comment.

Selectively Include jQuery Plugins


I’m often using jQuery and a little PHP because of the recent interest in the jQuery animation. Therefore I need lots of jQuery plugins to load in every web page. I need some plugins on each page such as Color plugin for the navigation and IE font-face ClearType fix for adding font-face support to IE, but I don’t need other plugins to load unless there is a page element specifically used with those plugins.

The Code


Here I defined a function that creates a script element before the end of body. The function basically used raw Javascript code to create script element and a line of jQuery code to append the new element to the body.

I used $(window).load instead of $(document).ready method to execute the jQuery code after the page is loaded. I then demonstrated the code for the font-face support for IE and the navigation color animation.

In order to selectively include jQuery plugins, check the existence of the element that requires to use those plugins first. I used if statement to check the length of the element. Include the jQuery plugins if the number of the specified element is at least one. Then execute rest of the code within the if statement. The screenshot below shows Firebug that the page has successfully loaded the required plugin.

Loaded required jQuery plugin successfully

Loaded required jQuery plugin successfully

Head over to to see it in action. Make sure to open Firebug when visiting the site to see which jQuery plugins are loaded. Right now only the homepage and Who We Are page use additional jQuery plugins.


If you have any question about the above code, feel free to post them in the comments below.

My Touchpad and Keyboard Solutions for Ubuntu on CR-48 / ChromeOS

Update (09/09/2011): I no longer use CR-48 because of its hardware limitation. The solutions in this post may not be working as Chrome OS kernel is updated frequently. Sorry for the disappointment.

Update (01/05/2010): As Pheonix7117 pointed out in the comment, here is the fix to the Touchpad issue in Ubuntu. Note that you don’t need to do the first step (Downgrade Xorg) and the last step (Broken Packages) if you are running Lucid (Ubuntu 10.04) on the CR-48.

Update (12/26/2010): For those of you never read comments (like me), Pheonix7117 has posted another tip for vertical scrolling using the touchpad. Here is the direct copy of Pheonix7117’s comment:

Here’s a temporary workaround to get *some* amount of scrolling working in the meantime:If you install the package ‘gpointing-device-settings’ it will add a menu entry to System > Preferences called Pointing Devices.
It *should* list a device called “PS/2 Synaptics TouchPad”.
What I did was enable wheel emulation and changed it to button 3 (which I believe is right click) and enabled vertical scroll. I left timeout and inertia default (inertia seems to be 0, timeout is fairly short) and left middle button emulation unchecked. This enables a regular right click when doing a ‘hard’ click in the bottom right corner without lingering, and if you hold the right click you can swipe a finger up or down to scroll. Granted, this isn’t using the touchpad driver at all as this is supposed to be used for regular mice, but it’s a start for getting by for now.

Update (12/21/2010): Pheonix7117 posted a Python script for controlling the xbacklight in the comments section. I only have a little understanding of Python language, but I think it’s a well-written script to control the backlight with the keyboard.


Ever since I installed Ubuntu on CR-48, I wondered about how to improve the touchpad speed and keyboard functions. I experimented with the touchpad driver today and noticed that while I can enable the touchpad tab inside the Mouse property with xinput, the options under the touchpad tab doesn’t seem to take any effect. Therefore I have to find other ways to configure the touchpad. The keyboard configuration was easy since all the functions are available in Ubuntu except for the right click, caps-lock and delete keys.


General setup – Under the general tab in the Mouse Preferences, move the Acceleration and Sensitivity sliders to the max fast and high respectively so that the cursor could move a little fast and reduce the chance to accidentally tap the touchpad while typing.

Left click and right click – The bottom left and bottom right corners of the touchpad recognize by Ubuntu as the left and right buttons, while toward middle of the touchpad doesn’t have any click event.

Middle click (Scrolling wheel) – I usually use the middle click on web pages when I want to open a link in a new tab. It doesn’t have a middle button on the touchpad. However, I can use Ctrl + tap to open a link to a new tab in most of the browsers. As for the most of the applications I use, none of them has middle click event except for games, which cannot run on this notebook because of the hard drive space limit.


The brightness keys – Install the xbacklight package, and assign the following commands to the corresponding keys on the first row of the keyboard through Keyboard Shortcuts window:

The volume mute, decrease volume, and increase volume keys – Change the default shortcuts for Volume mute, Volume down, and Volume up in the Keyboard Shortcuts window to the appropriate keys on the top row of the keyboard.

Right click, caps-lock and delete keys – As I stated earlier, I cannot find the functions for these keys since they are not available on the keyboard. However, you can use some remapping programs to remap these keys to the available keys.


Do you have any other touchpad and keyboard related tips for CR-48 (ChromeOS)? Please share them below. Also leave a comment below if you have any questions for this topic.

My First Tip on using Ubuntu with Chrome OS on CR-48 notebook

Update (03/15/2010): Based on Dan’s comment below, I’ve updated chromeos and ubuntu aliases in the post to remove the Chrome OS partition part. According to Dan, my previous aliases raised Chrome OS partition whenever the OS was switched, which means that when Chrome OS is updated, these aliases would restore the Chrome OS to the oldest version. For more information about this update, please read Dan’s comment.

Update (12/19/2010): I wrote a post on how to use your flash/USB drive to (re)install Ubuntu on the CR-48. Check it out.

Update (12/18/2010): I just discovered that .bashrc file is never executed in Chrome OS unless running another bash after chronos is logged in, and .profile is the file which being executed after each login. Therefore I changed the following instruction to .profile for Chrome OS. If you already created .bashrc file in the chronos home folder, you just have to rename it to .profile using the command below:


I have used the newly received CR-48 from Google for two days. I enjoyed so far for web browsing, but not so for web development / programming. Since I couldn’t find any good IDE on the cloud which has support for WebDAV, I decided to following the instruction on the Chromium Project website to install Ubuntu onto this device. After several hours of installation, Ubuntu loaded to the device. However, because it comes from a VirtualBox disk image, it’s nearly impossible to reinstall Ubuntu without re-transferring the disk image from my laptop to this notebook which is a 5GB file, it would spend another 5 hours just for transferring this file over ssh. I’m trying to shorten this long waiting hours. I will post another tip if I find a way. But for now, here are the two scripts I wrote to switch between Ubuntu and Chrome OS using the alias command.


First of all, I assume you also received a CR-48 notebook and installed Ubuntu on it by following on this page.

This first script is for Ubuntu:

  1. Open the file named .bashrc in the home folder  using your favorite text editor (make sure to show the hidden files by pressing Ctrl+H).
  2. Add the following line to the end of the file:

  3. Open a new terminal window to load the new alias.
  4. Type chromeos and a message will be displayed stating that you need to restart to switch to Chrome OS
  5. Restart your device and you are in the Chrome OS.

Now inside the Chrome OS:

  1. Press Ctrl + Alt + -> (the Forward button in the first row) and login as chronos
  2. Since Chrome OS also uses bash, we can write to the .profile file, but this time in the chronos home folder.

    The command above creates and opens a new file called .profile inside the home folder using the only text editor available in Chrome OS qemacs.

  3. Insert the following line into .profile

  4. Execute bash to launch another instance of bash, or if you are confused, you could just logoff current session by typing exit command and login again.
  5. Typing ubuntu command to switch to Ubuntu on the next startup.
  6. Restart your device to begin using Ubuntu.

In the future, you could just use chromeos and ubuntu commands to switch back and forth between Chrome OS and Ubuntu without changing back to normal mode using the small switch on the back of the battery.

Enjoy the free dual-boot notebook from Google.

Final Revision for Scrolling Animation Code

Final Revision for Scrolling Animation Code


After I revised the scrolling animation jQuery code yesterday, I was going to rewrite it using Mootools. However, I noticed that this code was doing two unnecessary actions. The first one is the removing of the first set of images, and another one is the appending of new sets of images. Several minutes after my eyes watched the scrollbar animate back and forth, I revised the code to the following.

The Code


In the above code, I removed the remove() action and added the append action at the beginning of the loop. It means that it will only has two sets of images available instead of an infinite loop that remove and append continuously to limit two loops which has slower performance.

After this revision, the animation lag still exists. This is probably the final revision of the code before I rewrite it using Mootools because I might discover some techniques during the rewriting of this code.

Revision for the Auto Scrolling Animation code

Autoscroll Animation


Since I wrote the auto scrolling animation code with jQuery, I struggled with the browser performance while running this animation. It seems that the animation needs lots of CPU power and it sometimes appears to be lagging. In order to solve the CPU issue, I included a jQuery plugin named Autoscroll. As the name applies, it automatically scrolls the specified element. This has the same feature as the code I wrote, but it’s a plugin and it will immediately stop the animation when in hover state whereas my code stops animation few seconds after the cursor was hovered over the element.

The Source Code

The following is the revised code:


As you can see in the code, I optimized the code to use the chaining method for jQuery.

I also changed the way images were looped. When scrollLeft greater than or equals to scrollWidth, the first set of images will be removed/deleted, pause the animation, set scrollLeft to zero, and restart the animation.

This means that when the position of the scrollbar reaches the beginning of the second set of images (or second loop), delete the first set of images using :first pseudo selector and reset the scrollbar position to the beginning. Since the scrollbar position will be at the end of the first loop and the beginning of the second loop, remove the first loop and reset the scrollbar position have no effect on the animation. The animation would continue to loop through the images without interruption but it’s limited to two loops.

Although the code was optimized, the animation still has some lag. It will sometimes stop and continue without interaction, much like the under-powered graphics card. I have not yet find any solution to this issue yet. However, I found out that Mootools animation is sometimes more smooth than jQuery. I will try to use Mootools to animate the auto scroll later.

Do you believe that Mootools animation is more smooth than jQuery? Please share your opinion in the discussion.