Archive for January, 2007


How to run your windows firefox on kubuntu with wine ?

January 28, 2007

I needed to run my windows firefox to retrieve some login (not password!) for things like my bank account…
Here comes an easy one, you’ll just need wine :
sudo apt-get install wine
Then you can launch your windows firefox (my partition is mounted on /media/sda1) :
Program\ Files/Mozilla\ Firefox/firefox.exe

The problem is that your profile won’t be loaded. At first I wanted to link (ln) the profile from windows partition but that wouldn’t work as I have the basic ntfs driver that mount the partition as read only, and firefox would complain (and anyway I wouldn’t want wine to put a mess in my windows firefox profile…). So you’ll just need to copy it :
/Documents\ and\ Settings/<YOUR_WINDOWS_USERNAME>\
/Application\ Data/Mozilla/Firefox/ ~/.wine\
/Application\ Data/Mozilla/

chmod -R 700 ~/.wine/drive_c/windows/profiles\
/<YOUR_KUBUNTU_LOGIN>/Application\ Data/Mozilla/Firefox

And you’re done, you can relaunch and your profile will be loaded.


How to get symlinks to point tv and webcam in a non random manner ?

January 27, 2007

Starting with 2.5x kernels, all physical and virtual devices in a system are visible to userspace in a hierarchical fashion through sysfs. udev is replacing the functionality of devfs.

The order in which devices with the same function appear in /dev is essentially random. E.g., if you have a USB web camera and a TV tuner, sometimes /dev/video0 refers to the camera and /dev/video1 refers to the tuner, and sometimes after a reboot the order changes to the opposite one.

To get round this problem we will identify our hardware and create correct symlinks pointing to the right device.
For that :
udevinfo -a -p /sys/class/video4linux/video0
I got :
looking at device '/class/video4linux/video0':
SYSFS{name}=="Creative Labs Webcam 5"

This is my webcam, I don’t have that much device identification for it apart from the name and dev.
For my pctv card i get :
udevinfo -a -p /sys/class/video4linux/video1
looking at device '/class/video4linux/video1':
SYSFS{name}=="BT878 video _Pinnacle PCTV Stud"
looking at device '/devices/pci0000:00/0000:00:09.0/0000:05:06.0':
looking at device '/devices/pci0000:00/0000:00:09.0':
looking at device '/devices/pci0000:00':

Here we get more identification for the pctv device, we will ignore the ones with DRIVER==””, so we have the first 2 to keep.
Now we can create /etc/udev/rules.d/83-duplicate_devs.rules with identifications in :
# Persistent symlinks for webcam and tuner
KERNEL=="video*", BUS=="pci", \
SYSFS{device}=="0x036e", SYSFS{vendor}=="0x109e", \
KERNEL=="video*", SYSFS{name}=="Creative Labs Webcam 5", \

Now you can reboot and change the kde shortcut of your xdtv (or any tvsoft that doesn’t autodetect the device) with the new symlink here :
xdtv -c /dev/tvtuner

For more information on the subject : refer to this.


How to make a simple image page counter / spyer in 20 minutes with Rails ?

January 27, 2007

At work I was a bit disappointed there is no counter on atlasian confluence wiki. I wanted to know whether my wiki page was being read by people and didn’t want to bug the admin to install the plugin for confluence. And this would be a good occasion to play with my beloved rails.

Prerequisites for your system (here kubuntu) :
I consider that you have rails installed (else sudo apt-get install rails), and mysql (else have a look here). You’ll also need to install mysql driver. First you need to install ruby packaging system : rubygems :
tar xzvf rubygems-0.9.1.tgz
cd rubygems-0.9.1/
sudo ruby setup.rb

Gem needs dev package aswell else you’ll land with a
ruby extconf.rb install mysql
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1

To fix that :
sudo apt-get install ruby1.8-dev
You’ll also need libmysqlclient12 and libmysqlclient-dev :
sudo apt-get install libmysqlclient12
sudo dpkg -i libmysqlclient-dev_4.0.20-2ubuntu1.7_amd64.deb

Finally you can install the driver :
sudo gem install mysql

Create your application skeleton by :
rails counter
Edit counter/config/database.yml and fill your database settings.
Now we will think about the model, what we need to keep ? IP, Browser, when the page was visited and the image visited, can’t be simpler.
ruby counter/script/generate \
model visit

Now you can edit counter/db/migrate/001_create_visits.rb that will be responsible for the database creation and future upgrades.
We will add the column we need :
class CreateVisits < ActiveRecord::Migration
def self.up
create_table :visits do |t|
t.column "ip", :string, :limit => 50, :default => "", :null => false
t.column "created_on", :timestamp, :null => false
t.column "browser_agent", :string, :limit => 100, :default => "", :null => false
t.column "resource", :string, :limit => 30
def self.down
drop_table :visits

Create the schema in mysql (either by commandline or with MySQLQuery Browser for example). Now you can create database table and columns by just running the rake goal :
cd counter
rake db:migrate

If you land on getaddrinfo: Name or service not known it’s likely that you didn’t install the mysql driver (detailed in Prerequisites section).
Ok, we have our db ready, our model, and skeletons.
We will need an image library to create the counter image. I’ll use the popular and easy to use RMagick :
sudo apt-get install libmagick9-dev
sudo apt-get install imagemagick
sudo gem install rmagick

And after some minutes you’ll end with : Successfully installed rmagick-1.15.0 On windows you’ll just need to gem install rmagick-win32

What will be doing our CounterController ? We will render an image showing number of people that requested this image, and add a line to the visits in database. I created an image with framebox public/images/frame_small.jpg to make the counter look a little bit better than a simple number. (Yeah I know I could have created it with RMagick too).
Let’s create our controller CounterController :
script/generate controller Counter
We will add the method show in CounterController (app/controllers/counter_controller.rb) :
def show
@target = @params[:id]
counter_image = \"public/images/frame_small.jpg")
text =
# We count the visitor for the given target resource
counter = Visit.count(:conditions => \
[ "resource = ?", @target])
# puts "Counter for " + @target + " - " + counter.to_s
text.annotate(counter_image, 0, 0, 0, 0, counter.to_s) {
self.gravity = Magick::CenterGravity
self.pointsize = 16
self.font_family = "Verdana"
self.stroke = 'transparent'
self.fill = 'red'
self.font_weight = Magick::BoldWeight
counter_image.format = "GIF"
counter_image = counter_image.to_blob
# The image is created, we can render it as is.
render :text => counter_image, \
:status => 200, :content_type => 'image/gif'

Let’s add a filter to add a line to database, with IP… from the visitor (here we resolve the IP to get the dns which is more talkative in local network as here it contains the name of the user) :
before_filter :complete_stats, :only => :show
def complete_stats
@visit ={:browser_agent => \
request.env['HTTP_USER_AGENT'], \
:ip => Resolv.getname(request.remote_ip.to_s).to_s, \
:resource => @params[:id]})
#puts "Visit created"
#puts "Visit creation failed"

Finally you can test it (-p 80 will specify the port it turns on).
ruby script/server -p 80
You can now browse http://localhost/counter/show/imageA.gif, http://localhost/counter/show/imageB.gif, each time you visit one of them it gets incremented. Now you can insert in any confluence page a link to one of those virtual counter images and keep tracks of your visitors!

Of course this is a really simple version, but enough for my needs. You might check the referrers, count only one visit per ip per day…
You can get rails sources here (easier to read than from this wiki).


How to get rid of the 10 minutes Blank Screen screensaver ?

January 27, 2007

You might not have noticed when you never happen to idle on your kubuntu more than 10 minutes, but a Blank Screen will be triggered. Not that embarassing you might think as there’s a big chance you’re away but well if there’s screensaver settings, it’s to configure that… And it becomes really irritating when you have a pctv card watching tv and that you have to move the mouse every 10 minutes.

So I couldn’t understand why this BlankScreen would appear although my settings in Desktop (right-click) / Configure Desktop / ScreenSaver was clearly using fireworks screensaver after 15minutes, and even after disabling it, I would still see this bloody BlanckScreen popping up. I thought it could be the Energy optimization from System Settings / Monitor & Display. But this one was set to 1 hour.

After some browsing on the net and some unsuccessful tries (with xset …) I thought I found it… in Desktop (right-click) / Configure Desktop / ScreenSaver / Blank Screen, unsetting the Start Automatically

Blank Screen Disabled

But that wouldn’t work either, finally I found a trick to disable this behavior thanks to ubuntu forum. In fact the problem appears when you run beryl with Xgl as a session on display :1. You’ll need to edit /etc/X11/xorg.conf and add at the end :
# To prevent Blank Screen from popping up every 10 minutes
# when xgl is run as a session on display :1,
# when all the power management settings
# you normally find only concerns display :0
Section "ServerFlags"
Option "blank time" "0"
Option "standby time" "0"
Option "suspend time" "0"
Option "off time" "0"


Playing with Beryl

January 21, 2007

My Beryl CubeToday I played a bit with Beryl. But firstly I needed to get the Super Key (Windows Key on Keyboard) working, this was accomplished by modifying Keyboard Section “InputDevice” in /etc/X11/xorg.conf with the following :
Option "XkbOptions" "altwin:super_win"
Now you can enjoy some more Beryl features, with the shortcuts (you can see snapshot of my desktop on the right) :

  • Pause Key or F8 : Scale Effect : Arrange and View All Windows
  • Ctrl + Alt + Left/Right Arrow : Switch desktops on cube
  • Ctrl + Shift + Alt + Left/Right Arrow : Switch desktops on cube – with active window following
  • Ctrl + Alt + left-click and grab desktop : Rotate cube manually
  • Alt + wheel mouse : Make window translucent/opaque
  • Super Key + wheel mouse up / down : Zoom-in/out manually
  • Ctrl + Super Key : Water
  • Shift + F9 : Rain

Also be sure to test the funky burn effect on windows minimizing through Beryl Settings Manager / Visual Effects / Animations / Minimize Animation => Burn


About FLOSS phenomenon, and the rest…

January 21, 2007

After 15 years of existence of GNU/Linux, can we measure the impact of it and the FLOSS phenomena ?
That’s what EUROPA ENTR Study did in a quite complete Economic impact of open source software on innovation and the competitiveness of the formation and Communication Technologies.
You’ll see a lot of interesting figures and statistics there. You’ll also read Macro-analysis, ie that the most impacted, and active region by FLOSS is Europe, then America, but China and Latin countries will soon overtake Europe.
After leading the field of supercomputing (Top500 Operating system Family), with 75.20% being Linux (17.20% Unix), OSS is gaining popularity in Operating Serrver Systems in companies (15.7% OSS in UK, Sweden, Germany).
While the North/South fracture is disappearing for some country in some domain, the digital fracture is present :
World Map of Commiters by population
Some other interesting questions from the study are :

1. What were the actual costs of developing a given set of software, in terms of time and effort and the equivalent in monetary terms?
2. What is the substitution cost of the same software – i.e. how much would it have cost to build the same software entirely within a single firm in a proprietary software development model33.

Then are given figures about Debian 3.1 FLOSS distribution (2005) :

Source lines of code : 221,351,503
If Debian was written in a software company…
Estimated effort : 163 522 person years
Development cost estimate (till 2005) : Euro 11.9 billion
Development cost estimate (till 2010) : Euro 100 billion
Copyright © 2006 MERIT. Source: URJC estimates (cumulative effort estimation), (salary data).

A note concerning this figure, it uses a COCOMO model adding complexity, without it it would be Person-Years = 2.4 * (KSLOC**1.05)) / 12 = 81915.
Firstly I didn’t know that latest Debian distros were that big, latest stats I read around about the Debian 2.2 potatoe were around 56 SLOC (56 Millions of Source Lines Of Code).
I guess that with those latest counts, X, Mozilla, Desktops are included.
Anyway what are 3 SLOC (for X), 6.2 SLOC (for KDE Snapshot / > 3.5.5), 1 SLOC (KOffice) next to the gigantic 221 SLOC.
You can do your own statistics using sloccount on your favorite projects (I did for X11R6.8.1, KDE Snapshot / > 3.5.5, I also did Beryl 0.1.4 : 0.2 SLOC).
So this has to be considered to the commercial equivalent Software :
Mac OS X 10.4 : 86 SLOC (Most of which must be from BSD…)
Vista : Said to be around 50 SLOC
So what to conclude the more SLOC, the better ? Not really, it’s hard to draw conclusion of the quality of a software only from the number of lines of code, but you can estimate the costs quite easily and you have an idea of how many license one needs to sale to make benefits.
Microsoft problem can be summed up easily :

Suddenly, the market changed and competitors started delivering technology at the speed of the Internet,” said James McQuivey, professor of market research at Boston University. “In some cases, they do it for free, and that’s painful for Microsoft.”

Vista is said to have cost 10 Billions Dollars, it is predicted to be installed on 76 Millions of computers, and should be responsible for $11.5 billion of profits by the end of June 2007.
That’s where we go and what European Study doesn’t emphasize, while there’s no doubt that the FLOSS is growing inside companies, the Personal Computer has a majority of Microsoft OS installed. So why Vista should be the last of it kind ?


Kubuntu and the small security improvements features to copy

January 21, 2007

There are 2 features I would like to see integrated (without using thirdparties software) in any OS that brings little security easily to the user and the machine :

  • The kdewallet : KDE Wallet aims to provide secure storage for passwords and web form data. You can group different passwords in different wallets, and each one will only be opened with a master password (which you should never forget!). The default wallet is named “kdewallet”, and you can either create a new wallet for your local passwords or accept the default wallet for all data in the “Automatic Wallet Selection” section.
  • Finally with Kubuntu during install I was surprised there was no prompt for root password but just <youruser> password. I find this restrictive politic of sudoing each time you need it really efficient and secure and the lambda user shouldn’t even know of the existence of root.

Play your legally purchased DVD in Kubuntu and get fined…

January 21, 2007

… At least that’s the case since 31dec 2006 in France too.
Your DVD player will complain that you’re not allowed to read DVD content and that you might use libdvdcss if the law in your country allows it (it won’t in USA and France at least).
If you live in one of those nice free country that allows it, just execute :
sudo /usr/share/doc/libdvdread3/
And you’re done, you can read your legally purchased DVDs…


Install xdtv on Kubuntu amd64

January 18, 2007

As I said in earlier post I wanted to install xdtv (on windows K!TV is the best soft I found around and xdtv is its linux version) but I couldn’t either set a full correct apt source neither find easily the amd64 deb from Marillat and I was a bit reluctant (or lazy) to compile it with the zillions of projects it depends on.
Finally found them here xdtv_2.3.3+2.4.0pre0-0.1_amd64.deb (it is referenced on xdtv site /Downloads).
You can try to sudo dpkg -i xdtv_2.3.3+2.4.0pre0-0.1_amd64.deb. But it’s unlikely to work directly. You’ll prolly need (find them either from depot or the web) :

dependency-step :

Finally you’ll hang on a last annoying dependency :
xdtv depends on libfaac0 (>= 1.24+cvs20060416); however:
Version of libfaac0 on system is 1.24clean-0ubuntu4.

As I didn’t want to backversion the lib with some cvs versions, I thought I would attempt to remove this dependency from the deb itself. Nothing easier :
dpkg-deb --extract xdtv_2.3.3+2.4.0pre0-0.1_amd64.deb \
dpkg-deb --control xdtv_2.3.3+2.4.0pre0-0.1_amd64.deb \

Now you’ll need to edit xdtv-custom/DEBIAN/control and remove libfaac0 (>= 1.24+cvs20060416), from it.
And finally rebuild the deb with :
dpkg --build xdtv-custom/ \

Finally you can install it
sudo dpkg -i xdtv_2.3.3+2.4.0pre0-0.1_custom_amd64.deb
Note : there might be some other thirdparties libraries missing (tvfonts, codecs…), do just like described on dependency-step.

Xdtv will also require ssuid, to fix that :
sudo chown root: /usr/bin/xdtv \
&& sudo chmod u+s /usr/bin/xdtv

You might encounter a problem seeing black screen when you launch xdtv and get only ‘Webcam’ as source and not ‘Television’, that is because your /dev/videoX taken into account is the wrong one. To check which /dev/videoX is the right one to use, you can either look at dmesg logs or (if you have xawtv installed) xawtv -hwscan which brought for me :
/dev/video0: OK [ -device /dev/video0 ]
type : v4l2
name : BT878 video (Pinnacle PCTV Stud
flags: overlay capture tuner
/dev/video1: OK [ -device /dev/video1 ]
type : v4l
name : Creative Labs Webcam 5
flags: capture

So just launch xdtv -c /dev/video0 (there must be a way to automate this detection), and you’re done, you’ll have the best image quality for your pctv on linux (The interface can’t be qualified “the best” but well I don’t care about the interface itself).


Kubuntu Install day!

January 14, 2007

I installed Kubuntu one week ago and thought I would share my experience toward that.

Firstly now that I have it installed, running, tweaked, I find it not so bad.
I have experienced quite a lot of os install :

  • For personal use : Debian (2.2, 3.0, Sarge), and the usual microsoft : windows9x/2k and XP.
  • For educational use : FreeBSD

And now it’s Kubuntu 6.10 Edgy turn, a Debian-based system.

I have to admit Kubuntu did a lot of effort on their install as it’s really easy to handle, with livecd (still I used to prefer the old interface with cfdisk … ;)). But when I installed the other os, I had been installing them on a newer machine while now it is 2 years old, so I won’t get the latest unresolved bug at install screen I had with the other install (sata not recognized for instance with Sarge DVDs…).

I experienced a small problem with grub that would install on an old ide hard drive used only for backup, the faster solution I found was to unplug the harddrive and reinstall with only my sata harddrive plugged (yeah I know I should have played with the hdX,X but had no fun…). By the way speaking of grub that I had installed since Debian Sarge, that’s a great and easy to use booter. I’m happy that LILO belongs to the past.

It took 1 hour to install (incl partition ordering/formatting), and I had a working linux running X (X was a big pain to handle in the past, it’s still a bit when you want the latest drivers working). It detected the other partitions (windows) and mounted them in media.

The ppoeconf was fastly configured (when you know it’s called that way) so I had inet 2minutes after install.

Ok now first problem, how do I increase resolution, I’m stuck at 1024 and 60Hz and my eyes don’t like that. Incredible, my (5 years old) iiyama screen is in the list! Ok click on ‘Test’ and you’ll get a blackscreen and noway to get rid of it even with ctrl-alt-F1… Ok reboot… Try again but with apply directly, cool I can view the effect now…

Ok now drivers, firstly a good idea is to save your /etc/X11/xorg.conf. Firstly tried the ubuntu way from Ubuntu Edgy Installation Wiki Guide. Unfortunately, with the ubuntu way of install I would get a DRI Initialization failed in /var/log/Xorg.0.log, and after installation of the drivers the manual way and a sudo aticonfig –initial then I would get a black screen of the death at login startup with my screen being requested 95Hz that it doesn’t support. So I took back my xorg.backup.conf uninstalled previous drivers and reinstalled the manual way and aticonfig –initial from my clean xorg.conf. Neat, I got it with DRI!!

Then wanted to listen to some Music, so I launched Amarok but it wouldn’t be able to grab the mp3 codec from the net (now it’s working good), So I switched to xmms which worked but had crazy fonts when browsing file system for mp3 (I didn’t fix that yet).

Ok, I find Konqueror better with each linux distro I installed in time, but my favorite webbrowser is : firefox. Naive as I am I tried to apt-get it without success, It would only bring me some patches… So I tried to install it from Mozilla but it complained that it doesn’t find the executable although I am 100% sure it is here… In fact this is the non-explicit message you’ll get each time you install an i386 binary on your amd64 architecture. After some search and some unsuccessful tries, I ended on an Ubuntu forum post How to install 32 bit Firefox with flash, it worked like charm!

While all this, I encountered a major problem with my keyboard : I was not able to type the essential key ‘|’ and several others you get while pressing ‘Alt Gr’. Also / * – + from keypad were not working, not that I use them that much but it’s faster when you have some calculus to do.
This was solved creating $HOME/.Xmodmap with :
keycode 113 = Mode_switch
keysym KP_Divide = slash
keysym KP_Multiply = asterisk
keysym KP_Add = plus
keysym KP_Subtract = minus

This won’t work as I read here and there that xmodmap is deprecated and that xkb should be used instead. For the moment I’ll just add xmodmap ./Xmodmap to my $HOME/.bash_profile. I’ll play with xkb later.

Ok, For the moment we stayed with the basis, I wanted to give a try to beryl 3d desktop manager version 0.1.4. I followed the simple Beryl Installation For Edgy but without success as when I would run beryl-manager I would end with a non-explicit message (again) : Beryl caught deadly signal 11. After some reading around the net I downloaded rearranged amd64 beryl package beryl-0.1.4.tar.gz that I got from Ubuntu Forum. It worked like charm, and then I had to admit I was really surprised by this nice and new Desktop!

Finally, I wanted to have my pctv working so I installed kdetv Viewer. It’s not bad but the screen is scrambled on certain screen size. Then I tried with XawTv, but their interface didn’t change and is still unfriendly… Wanted to try xdtv but couldn’t find the latest deb for amd64 so I took older one (I didn’t want to compile it, as it depends on zillions of lib and that I had better stuff to do than spending time on that), but without success. Finally the award winning for tv watching on my ubuntu was tvtime. But still the rendering without overlay is worse than with K!TV on Windows.

To draw a conclusion, I would say that Kubuntu managed to put one of the best distro around (Debian) available for Desktop users easily. Once configured you’ll have a good Desktop (I’ll blog about that later cause I still have criticism about that). But if you want it perfect, it will take you quite a lot of time to get to the result you want, lambda user doesn’t want that! He wants to click, reboot X times and that’s it…
Now a programmer can spend some more time to get his best Integrated Development Operating System Environment.