Monday, May 21, 2012

Some tar tips.


Some small useful tips I keep forgetting from time to time. Just blogging them
so I can find them easily.

Clean up messy tar files

Some people like to create tar files without a parent folder. These, when
extracted, fill the current directory with lots of files and folders messing up
your neatly ordered file structure.

Fortunately with a any of the following two commands you can quickly find and
delete all the offending files and folders:

Decompress any type of tar

To extract files from compressed tar files we needed different commands depending on the compression format (-j for bzip, -z for gzip...). With newer tar versions there is a -a switch that decompresses all formats:


Thursday, April 26, 2012

Canon Satera LBP5910 Linux Driver 2.40 (Ubuntu Oneric 11.10)


After upgrading to Ubuntu 11.10 Ocelot 64bit my printer stopped working and took me a long time (almost a month) to get it working again (for previous version of Ubuntu refer to this post [1]). Actually after Ocelot a lot of Canon printers stopped working like the MF4350d [2] with a wide range of errors such as /usr/lib/cups/filter/pstoufr2cpca failed or missing dependencies from deprecated packages. After trying all solutions on the Internet the only one that worked for me was compiling from source as explained in a japanese blog post [3].

Installing Canon LBP5910 Driver 2.40 in Ubuntu Ocelot (11.10)

Download the source code

Go to the following URL: and press the button that looks like: "ダウンロード開始". This will download the driver source code into you machine.

Install some dependencies and build packages

Install the common driver package

Install the LIPS4 driver

I tried first with the LIPSLX driver but I could not print so I installed the LIPS4 driver instead. First we need to unpack the driver source files: then we need to patch the build script: You can get the patch from gist Once patched you can compile and install the driver with: Note that you must use sudo when running "" or the build will fail with missing header files (e.g. cnpklib.h). Finally we can restart the cups service to make sure it loads the new driver and PPD definition files:

Configuring your printer

Now you can use the printer configuration tool that comes with your distribution or the cups web interface http://localhost:631/ to configure the printer. Some pointers when configuring it:
  • Use the IPP protocol.
  • In the list of drivers select Canon LBP Color Series LIPS4 ver.2.4


  • [1]
  • [2]
  • [3] href="

Tuesday, February 22, 2011

Google contacts with sup email client.


Recently I found about sup [1] and gave it a try to replace mutt. One of my requirements is access to my Gmail contacts from within the client so I can auto-complete the To, CC and BCC fields with my already registered contacts.

Fortunately I already had a ruby script to integrate Gmail contacts with mutt [2] and since sup can be extended via ruby scripts it was extremely easy to get my script working with sup.

SUP email client with Gmail contacts

Sup hooks system [3] is very powerful and allows us to add all kinds of functionality to sup using simple ruby scripts. One such hooks is called "extra-contact-addresses.rb" and from the hooks documentation we can read:

What this means is that we must create an script inside our $HOME/.sup/hooks directory called extra-contact-addresses.rb that returns an array of email addresses in plain format (e.g. or full format (e.g. User Name <>).

Here is the script I implemented for this purpose:

Simply copy this script to "~/.sup/hooks/extra-contact-addresses.rb" and your are ready to go. When composing or replying and email you can press Tab to autocomplete email addresses.



Wednesday, December 29, 2010

Get KDE 4 .4.2 working with xrdp

Problem Statement

KDE4 [1] looks horrible when accessed remotely via vnc [2] and since xrdp [3] is simply a proxy that depends on vnc we get the same horrble look when accessing KDE using Windows RDP client.

The usual response from KDE developers is that vnc is bad and you should change your vnc server or use another remote desktop technology so I tested all vnc server implementations I found and I can tell that x11vnc is the only one that is simple and works correctly with KDE4 so the solution to my problem was simple: get xrdp to work with x11vnc.

Configure KDE4 with x11vnc server

This cannot be more easy. In Ubuntu simply install the package:

then in a terminal (konsole) run this command:

The first time you run this command it will ask you to input a password. Choose any one you like and remember it because you will need it to connect remotely to x11vnc. The -noxdamage option is only needed if you have desktop effects enabled in plasma. If you have these plasma effects enabled and you do not use the -noxdamage option you will see some XDamage errors in the x11vnc output. You can also ask x11vnc to turn off the monitor when a remote client connects using the -clientdpms option and to lock the screen when the client disconnects using the -gone option. Be warned that the -clientdpms and -gone options were not working very well last time I tried. For example is difficult to recover the session from the desktop unless the remote client

Configure KDE4 with xrdp server

Install the xrdp packages:

Edit the /etc/xrdp/xrdp.ini file and add an entry like:

Finally restart xrdp service:

Accessing remotely you KDE session via Windows RDP client

In a windows machine open the remote desktop client (usually found in accessories) and input your KDE machine IP address. After the connection is established you will get a popup with some options including the one we created above (MyHOME) so select it, input the password you set to x11vnc and enjoy.


If you use Gnome instead of KDE you be encounter a bug that messes up the keyboard [6]. To fix it you must disable the keyboard plugin of the gnome-settings-daemon using hte gconf-editor. To do this open the gconf-editor and navigate all the way to the folder:

and set the active option to False.

Enabling the Kana Henkan key (Japanese Keyboards)

To get the japanese kana key (top left in japanese keyboards) to work you need to apply a patch
[7] and install the patched deb:



Saturday, November 06, 2010

2010 Vim Configuration

Monday, May 10, 2010

Japanese Input in Lucid Lynx (Kubuntu 10.04)


Since Kubuntu 9.10 there is a movement to replace skim [1] with ibus [2] that seems to be a better alternative. Unfortunately after my latest upgrade to Kubuntu 10.04 this movement caused my Japanese input to stop working.

To get Japanese working again using ibus was actually very easy and here Iexplain the steps to do it.

Uninstall SCIM/SKIM packages

First we uninstall all SCIM and SKIM related packages to avoid any kinds of conflicts with the new iBus system.

Install iBus required packages

Second we install the iBus packages needed to support different language input methods.

Configure the system to auto-select the input method.

The im-switch utility is used to select input methods. For better results make sure you select auto.

Trouble Shooting

  • Japanese/Chinese/Korean/etc does not work in any applications.
  • Make sure you have all scim/skim related packages uninstalled and all required ibus packages installed. Also make sure you ran the im-switch command (with sudo) and set ibus in auto mode.
  • Japanese/Chinese/Korean/etc input work in KDE apps but no in GTK (Firefox, Chrome, Skype) apps!
  • This happens if you do not have the ibus-gtk module installed or do not set the im-switch to auto.
  • Japanese/Chinese/Korean/etc input work in GTK (Firefox, Chrome, Skype) apps but no in KDE apps!
  • This happens if you do not have the ibus-qt4 module installed or do not set the im-switch to auto.


[1] scim/skim

Sunday, March 21, 2010

Get offlineimap working with non ASCII characters.


I recently started using offlineimap [1] to manage my GMail accounts locally on my machine.

With offlineimap all my email is local so the navigation is very fast and also I am a little more relieved that I have a local copy of all my email.

The only problem is that offlineimap does not work well with non english characters. This makes it difficult to use for those with labels in Russian, Chinese, Japanese etc [2].

Fortunately offlineimap offers some nice options that allows us to modify it's behavior. Using the "pythonfile" and "nametrans" options I was able to get Japanese working flawlessly.

Problem Description

IMAP4 uses a modified UTF-7 coding for all folder names but offlineimap does not convert the folder names to UTF-8 or something readable before creating local repositories that results in very cryptic folder names like "&MMYwuTDI-".

Some research (googling) on the topic resulted in a very nice code to add IMAP4 UTF-7 encoding capabilities to Python [3]. So with a little time and some copy/paste skills I added this code to offlineimap and ban! I got Japanese working correctly in my folders.

Fixing unicode issues in offlineimap

First we must add the code to convert from IMAP4 UTF7 encoding support to offlineimap. Thanks to Dominic LoBue (offlineimap developer) I learned that we can add our own python code to offlineimap. To do this we created a simple python script (e.g. ~/ that contains the following code (copy/paste from [3]:

Then in our offlineimap configuration file, in the "[general]" section we add a line to load this python script like:

Finally in our remote repository configuration add a nametrans option to convert all foldernames from "imap4-utf-7" encoding to your encoding of preference. My Ubuntu installation is all UTF-8 so I convert all folder names to this encoding:

The "imap4-utf-7" encoding is added by our "" script. With this configuration I can now see the correct Japanese names for all the folders (labels) in my GMail accounts inside Mutt [4].


[3] IMAP4 UTF-7 Encoding/Decoding
[4] Best email client