Archive for the ‘linux’ Category

h1

ScreenCast on Linux

March 17, 2007

I needed to do some screencast on my PC. After reading around the net I found vnc2swf and Istanbul. I decided to give a try first to Istanbul as it had a deb package ready. I am a bit reluctant to installing gnome based software and their lib on my KDE but well…
So well, the usual :
sudo apt-get install istanbul
But at launch I would end with :
Traceback (most recent call last):
File "/usr/bin/istanbul", line 30, in ?
from istanbul.main import main
File "/var/lib/python-support/python2.4/istanbul/main/main.py", line 33, in ?
from istanbul.main.gconf_client import GConfClient
File "/var/lib/python-support/python2.4/istanbul/main/gconf_client.py", line 19, in ?
import gconf
ImportError: No module named gconf

I read that it was fixed with later version of Istanbul, So I went to install the new version. But first you’ll need newer libxml2 library aswell (here link for amd64) :
wget http://http.us.debian.org/debian/pool/main/libx/libxml2/libxml2_2.6.27.dfsg-1_amd64.deb
sudo dpkg -i libxml2_2.6.27.dfsg-1_amd64.deb

wget http://http.us.debian.org/debian/pool/main/i/istanbul/istanbul_0.2.1-3_amd64.deb
sudo dpkg -i istanbul_0.2.1-3_amd64.deb

Later if a software require older version of libxml2, you can overwrite the newer you installed with the previous ubuntu version, istanbul should continue to work correctly.
You’re done, you can launch and record through the icon in tray bar.

It’s really easy to use but the output is only OGG Theora and unfortunately web browsers don’t all handle that format.

That’s why I switched to vnc2swf which produces directly flash format.
Couldn’t be easier to install, you need a vnc server, ie :
sudo apt-get install x11vnc
Then install vnc2swf. I installed pyvnc2swf as it’s the one under development and maintained contrary to the C older version.
sudo apt-get install python-tk
sudo apt-get install python-pygame
wget http://www.unixuser.org/~euske/vnc2swf/pyvnc2swf-0.9.1.tar.gz
tar xzvf pyvnc2swf-0.9.1.tar.gz
cd pyvnc2swf-0.9.1/

Now you can launch vnc server :
x11vnc -localhost -viewonly -wait 10 -defer 10 &
And you can launch vnc2swf :
python vnc2swf.py
You might land on this message :
open /dev/sequencer: No such file or directory
You should install kernel module : kernel/sound/pci/emu10k1 as stated here.

h1

Upgrading to Beryl 0.2.0

March 17, 2007

Beryl 0.2.0 is out with many cool features and fixes :

    New Plugins :

  • Thumbnail: Thumbnails on the taskbar (window list) which show a mini view of the actual window
  • Snap: Allows windows to “snap” to each other, or provide edge resistance
  • Opacify: Makes windows behind the active window transparent
  • Group: Allows windows to be group, to easily switch between a set of windows
    New system requirements check :

  • The improved check has much better accuracy
  • The check is a lot faster
    New Window Decorators :

  • Since 0.1, we have two new window decorators
  • Heliodor: Uses metacity themes
  • Aquamarine: Uses Kwin themes.
    Newly Rewritten Beryl-Settings :

  • Written in Python
  • More user-friendly UI
  • Better profile support
    New Translations :

  • Thanks to all of our foreign speaking users, we’ve had a much better time getting translations

Now how to upgrade your version (mine used to be 0.1.4) on your kubuntu edgy ?
Edit your /etc/apt/sources.list and add the following lines :
deb http://ubuntu.beryl-project.org edgy main
deb-src http://ubuntu.beryl-project.org edgy main

Update the list :
sudo apt-get update
And upgrade the following packages :
sudo apt-get install beryl
sudo apt-get install beryl-core
sudo apt-get install beryl-manager
sudo apt-get install beryl-plugins
sudo apt-get install beryl-plugins-data
sudo apt-get install beryl-settings
sudo apt-get install emerald
sudo apt-get install emerald-themes
sudo apt-get install libberylsettings0
sudo apt-get install libberylsettings-dev
sudo apt-get install libemeraldengine0
sudo apt-get install libemeraldengine-dev

Reboot and enjoy!

h1

Installing RadRails on Ubuntu Edgy amd64

February 13, 2007

For a future post about Ruby IDE I needed to install RadRails. I did it in the past without problem on windows. Unfortunately the official (and snapshot) versions come with a 32 bits shared library (libswt-pi-gtk-3232.so). So I was landing on an error message quoted later. The only solution I read while investigating on the net was to use RadRails the oldway : install Eclipse and add RadRails and RDT Plugin to it… I didn’t want to download the overbloated eclipse platform while a standalone RadRails version exists which is lighter (still 40MB…) So I convinced myself to get those bloody 64 bits shared libraries to work.
The laziest way is to find a solution without any compilation (compilation of such libraries can be a nightmare when they depend on zillions of projects and I have no fun messing with that anymore).
So let’s go!
Download Eclispe RPC eclipse-RCP-3.2.1-linux-gtk-x86_64.tar.gz from eclipse site.
wget http://sunsite.informatik.rwth-aachen.de/eclipse/downloads/drops/R-3.2.1-200609210945/eclipse-RCP-3.2.1-linux-gtk-x86_64.tar.gz
Untar
tar xzvf eclipse-RCP-3.2.1-linux-gtk-x86_64.tar.gz
Get RadRails (0.7.2 or snapshot) from RadRails site
wget http://www.web20.com/downloads/radrails-0.7.2-linux-gtk.tar.gz
Untar
tar xzvf radrails-0.7.2-linux-gtk.tar.gz
Launch RadRails once (you need to do that to init RadRails configuration)
./radrails/RadRails
An error message will popup :
An error has occurred. See the log file
/del/radrails/workspace/.metadata/.log.

By editing this file you’ll read that a 32 bits shared library is doing some mess
!STACK 1
java.lang.UnsatisfiedLinkError: /del/radrails/radrails/configuration/org.eclipse.osgi/bundles/59/1/.cp/libswt-pi-gtk-3232.so: /del/radrails/radrails/configuration/org.eclipse.osgi/bundles/59/1/.cp/libswt-pi-gtk-3232.so: wrong ELF class: ELFCLASS32
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1660)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)

Backup the existing faulty jar containing the bloody 32 bits library.
mv radrails/plugins/org.eclipse.swt.gtk.linux.x86_3.2.0.v3232m.jar radrails/plugins/org.eclipse.swt.gtk.linux.x86_3.2.0.v3232m.jar.backup
And replace it with the jar you downloaded from eclipse site containing 64bits shared libraries (like libswt-pi-gtk-3235.so)
cp eclipse/plugins/org.eclipse.swt.gtk.linux.x86_64_3.2.1.v3235.jar radrails/plugins/org.eclipse.swt.gtk.linux.x86_3.2.0.v3232m.jar
You can finally relaunch RadRails!

h1

Installing Miro PCTV Remote Control to run with xdtv

February 8, 2007

I was missing my PCTV Remote control from Windows so I couldn’t lazily switch off my pc by air anymore 🙂
So I decided to install lirc.
I though a simple sudo apt-get install lirc would be enough, but that was not. I wouid get the error message :
could not get file information for /dev/lirc
And indeed /dev/lirc didn’t exist.
So I looked again on the quality ubuntu forum to find the solution that I updated a bit here.
So I decided to install middle-way from apt and oldway.
wget http://prdownloads.sourceforge.net/lirc/lirc-0.8.1.tar.bz2
tar xvjf lirc-0.8.1.tar.bz2
cd lirc-0.8.1/
./configure
# here setup will prompt you
# for your hardware settings :
# PCTV / COM port...
# with a sweet dialog display
# else you should edit /etc/lirc/hardware.conf
# and
# sudo cp /usr/share/lirc/remotes/\
# pinnacle_systems/lircd.conf.pctv \
# /etc/lirc/lircd.conf
make
sudo make install
# backup
sudo mv /usr/sbin/lircd /usr/sbin/lircd-original
sudo mv /usr/sbin/lircmd /usr/sbin/lircmd-original
# if you installed lirc through apt-get previously
sudo rm /dev/lirc
# install the apt-way
sudo apt-get install lirc
# finish the oldway install
sudo make install
# and replace the apt binaries
sudo cp /usr/local/sbin/lircd /usr/sbin
sudo cp /usr/local/sbin/lircmd /usr/sbin

Now that all is installed it’s time to test it.
Launch in one terminal :
sudo /etc/init.d/lirc stop
sudo lircd --nodaemon

And launch in another terminal lirc tool :
irw
Now you can type on your pctv remote and you should see in this terminal some things like :
00031 00 1 PinnacleSysPCTVRemote
00031 00 1 PinnacleSysPCTVRemote
00031 01 1 PinnacleSysPCTVRemote
00031 02 1 PinnacleSysPCTVRemote
00032 00 2 PinnacleSysPCTVRemote

Now you can edit your settings (~/.lircrc) to make it work with xdtv. (.lircrc content doc)
Ok so now you can restart it correctly as daemon.
sudo /etc/init.d/lirc restart

h1

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) :
wine /media/<YOUR_WINDOWS_PARTITION>/\
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 :
cp -R /media/<YOUR_WINDOWS_PARTITION>\
/Documents\ and\ Settings/<YOUR_WINDOWS_USERNAME>\
/Application\ Data/Mozilla/Firefox/ ~/.wine\
/drive_c/windows/profiles/<YOUR_KUBUNTU_LOGIN>\
/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.

h1

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':
KERNEL=="video0"
SUBSYSTEM=="video4linux"
SYSFS{name}=="Creative Labs Webcam 5"
SYSFS{dev}=="81:0"

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':
KERNEL=="video1"
SUBSYSTEM=="video4linux"
SYSFS{card}=="39"
SYSFS{name}=="BT878 video _Pinnacle PCTV Stud"
SYSFS{dev}=="81:1"
looking at device '/devices/pci0000:00/0000:00:09.0/0000:05:06.0':
ID=="0000:05:06.0"
BUS=="pci"
DRIVER=="bttv"
SYSFS{modalias}=="pci:v0000109Ed0000036Esv000011BDsd00000012bc04sc00i00"
SYSFS{local_cpus}=="01"
SYSFS{irq}=="66"
SYSFS{class}=="0x040000"
SYSFS{subsystem_device}=="0x0012"
SYSFS{subsystem_vendor}=="0x11bd"
SYSFS{device}=="0x036e"
SYSFS{vendor}=="0x109e"
looking at device '/devices/pci0000:00/0000:00:09.0':
ID=="0000:00:09.0"
BUS=="pci"
DRIVER==""
SYSFS{modalias}=="pci:v000010DEd0000005Csv00000000sd00000000bc06sc04i01"
SYSFS{local_cpus}=="01"
SYSFS{irq}=="0"
SYSFS{class}=="0x060401"
SYSFS{subsystem_device}=="0x0000"
SYSFS{subsystem_vendor}=="0x0000"
SYSFS{device}=="0x005c"
SYSFS{vendor}=="0x10de"
looking at device '/devices/pci0000:00':
ID=="pci0000:00"
BUS==""
DRIVER==""

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", \
SYMLINK+="tvtuner"
KERNEL=="video*", SYSFS{name}=="Creative Labs Webcam 5", \
SYMLINK+="webcam"

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.

h1

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 :
wget http://rubyforge.org/frs/download.php/16452/rubygems-0.9.1.tgz
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
wget http://security.ubuntu.com/ubuntu/pool/main/m/mysql-dfsg/libmysqlclient-dev_4.0.20-2ubuntu1.7_amd64.deb
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
end
end
def self.down
drop_table :visits
end
end

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 = \
Magick::ImageList.new("public/images/frame_small.jpg")
text = Magick::Draw.new
# 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'
end

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
private
def complete_stats
@visit = Visit.new({:browser_agent => \
request.env['HTTP_USER_AGENT'], \
:ip => Resolv.getname(request.remote_ip.to_s).to_s, \
:resource => @params[:id]})
if @visit.save
#puts "Visit created"
else
#puts "Visit creation failed"
end
end

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).