Monday, June 18, 2012

Android emulator gives "SDL init failure" error on Ubuntu/Linux

If you are getting the following error:
SDL init failure, reason is: No available video device
from Android emulator on a Unix/Linux platform, this typically indicates your shell's DISPLAY variable is not pointing to the correct X11 Display. Try launching the Android emulator as shown below. You may add your own parameters as needed as long the DISPLAY=:0 is there.
DISPLAY=:0 emulator -kernel your_zImage -system your_system.img -ramdisk your_ramdisk.img -sdcard your_sdcard.img


Wednesday, June 13, 2012

Disable New Tab Page in Firefox 13

Firefox 13 introduced something called "New Tab Page" which shows a history of 9 most visited pages in a tile interface, much like the way Google Chrome does. Actually it looks like the picture below:


But, there are two problems with it. First, if you don't want your browsing history to be shoulder-surfed (someone looking at your browser over your shoulder), this is not a good thing. Second, it actually makes the new tab open a slighter slower than before for which the reason must be obvious.

Anyway, since there's no point-and-click kind of configuration options anywhere in Firefox 13 to turn this feature off, we need to edit Firefox's hidden global configuration settings. This settings interface can be reached by typing "about:config" in the address bar and pressing enter. It will show you a plethora of Firefox's internal options. Most of these options are explained in "Mozilla Knowledge Base". In order to turn off the new tab page, the two relevant options are:
  1. browser.newtab.url
  2. browser.newtabpage.enabled
You can quickly locate these two by typing "newtab" in the search bar. As the name suggests, the first option is set to "about:newtab" as default which is the page that displays the 9 most visited page links in tiled interface. We can set it to "about:blank" to force disable the new tab page feature. The second option is better is setting it to "false" (by right clicking and selecting "Toggle" from the menu) will disable new tab. Next time we click the plus icon in the tab-bar or press Ctrl+T, Firefox will open new tab page without the tiled history links. Cheers!

Thursday, June 7, 2012

Ubuntu 12.04 – How to use VNC even at the login prompt


I have a partially headless desktop machine on my desk only connected with a monitor. I typically use this machine for heavy duty computation or simulation. The machine is more than decent hardware wise. But I have a decent enough laptop where I like to keep all my day to day stuffs. Given the scenario, if I should ever have to use keyboard and mouse on the desktop machine, I would typically use Synergy to control the desktop using the keyboard and mouse from my laptop. Since the desktop has a much larger screen, it is quite convenient that way for many specific things. The desktop runs a SSH server. So, I can login over SSH and start the Synergy client which would connect back to the Synergy server running on my laptop. The setup is actually quite handy.

Now, there’s a catch. The problem is that synergy refuses to bind to the keyboard and mouse on the desktop machine due to missing X authentication credentials at the login prompt. Since at the login prompt, the user (me@desktop) hasn’t logged in yet. So, he (me@desktop) doesn’t have a proper X credential yet. Apparently, there is no easy way to pass the custom MIT-MAGIC-COOKIE to synergy. Therefore, I decided to fall back to VNC, which is also occasionally useful when I am working remotely.

Ubuntu 12.04 Precise Pangolin (I think 11.10 too) comes with LightDM as the login and display manager. Therefore, the desktop environments such as GNOME, KDE or LXDE would be started by LightDM only after the login has been successful. As mentioned before, Synergy can’t work in this phase because the X server authentication credentials from LightDM can not be passed easily. Therefore, to type in the password at LightDM login prompt, I use x11vnc. On Ubuntu, a quick “apt-get install x11vnc” will install it. The reason I like it a lot is mostly because it can be used like a regular console utility to start-up the VNC service. For example, I could just do “x11vnc –display :0” to quickly setup a VNC session over SSH and then login remotely over VNC. The additional benefit would be that VNC will be passed thru SSH (by means of SSH port forwarding), it will be way more secure than just plain VNC. So, coming back to where we were - to start x11vnc at the login prompt, a typical “x11vnc –display :0” wouldn’t work. Because the X server will refuse authentication as we need the authentication credentials for the LightDM service which is started as “root”. x11vnc provides an “-auth auto” option. But, it will also mostly likely fail because the “.Xauthority” file wouldn’t be found.

To get around this, we need to locate the right “.Xauthority” file where the MIT-MAGIC-COOKIE is saved. After some snooping around on my file-system, it appears that the LightDM service stores it’s files in “/var/lib/lightdm” directory. Great! now if we just do a “sudo x11vnc –display :0 –auth /var/lib/lightdm/.Xauthority” x11vnc will run in the login prompt and we will be able to use VNC even after login .

So, to recap, the steps are:

  • apt-get install x11vnc openssh-server
  • Reboot the machine (or log-out). In my case it’s my desktop.
  • ssh user@desktop. I would do it from my laptop.
  • sudo x11vnc –display :0 –auth /var/lib/lightdm/.Xauthority
  • Now, from my laptop I can use any VNC viewer to connect my desktop even in the login prompt.