Archive for Linux

New Mouse in Xorg

Last Week I updated my Gentoo box from Xorg 6.x to Modular Xorg 7.0, which is radically different: Xorg now consists of a bunch of small modules instead of a big package.

I didn’t encounter many problems during this upgrade, and you shouldn’t as long as you follow the gentoo migration guide.

This week, I bought a new “gamer” mouse: the Trust “Predator” GM-4200.

Of course, I wanted all buttons to be active and usable in X. So here’s the way I’ve followed to make it working:

First I had to re-emerge Xorg, but with the evdev module integrated. So I added “evdev” into the “INPUT_DEVICES” section of /etc/make.conf:

INPUT_DEVICES=”keyboard evdev mouse wacom”

Then I modified the xorg.conf file:

Section “InputDevice”
Identifier “Mouse1”
Driver “evdev”
Option “Device” “/dev/input/event1”
Option “Buttons” “10”
Option “ZAxisMapping” “4 5”
Option “AlwaysCore” “on”
EndSection

You can see that I defined this mouse with 10 buttons, altough it physically has only 8. In fact, buttons 6 and 7 are automatically assumed as being the left and right wheel tilt (option I don’t have on my mouse). At that point, all my buttons are recognized, but still not usable.

So, finally, I installed xvkbd and xbindkeys, and added the following into my ~/.xbindkeysrc file:

# Back using button 8
“xvkbd -xsendevent -text “\[Alt_L]\[Left]””
b:8
# Forward using button 9
“xvkbd -xsendevent -text “\[Alt_L]\[Right]””
b:9
# Close TAB using button 10
“xvkbd -xsendevent -text “\[Control_L]\[w]””
b:10

After launching xbindkeys (you may want to add it in the automatically started applications), the defined action will be performed after pressing the correspondant mouse button: buttons 8 and 9 navigate backward and forward in Firefox, and button 10 closes active Tab.

Automatic Keywords Generation

I just wrote a small php function that automatically generate HTML meta keywords from the custom “tags” field of the displayed posts:

#########################
# KEYWORDS GENERATOR #
#########################/*
This function generate HTML Keywords based on
the tags filled in for the displayed posts.
Requirements: WordPress 2.0, and you have to manually enter
the tags separated by a comma in the ‘custom fields’ (named tags)
part of the post.
TODO: actually, it’s only applicable to the first page (5 posts).
It will be updated soon to all post pages.
Author: harck (jerome.harckmans.be)
*/
function keywordGen() {

// Global Settings
$num_posts = 5; // Number of posts per page
$db_name = “WordPress Database Name”;
$db_user = “WordPress Database User”;
$db_pwd = “User Password”;
$db_host = “WordPress Database Host”;
// connecting to DB
mysql_connect($db_host, $db_user, $db_pwd) or die (“Unable to connect to Database Server!”);
mysql_select_db($db_name) or die (“Unable to select Database!”);
// Get all tags for the $num_posts last posts
// (the $num_posts displayed in the home page)
$tags = mysql_query(“SELECT meta_value FROM wp_postmeta, wp_posts WHERE post_id = ID AND meta_key = ‘tags’ ORDER by post_date DESC LIMIT $num_posts “);
// Get the number of tags lines (may be different from $num_posts)
$num_tags = mysql_numrows($tags);
// Loop for each tag line
for ( $i = 0; $i < $num_tags; $i++ ) {

// Get current tag line
$cur_tags = mysql_result($tags, $i);
// First time, $keywords = tags
if ( $i == 0 ) {

$keywords = $cur_tags;

}
// then append tags to $keywords
else {

$keywords = $keywords.”,”.$cur_tags;

}
}
// Print HTML Keywords Meta
print(”

<meta name=\”Keywords\” content=\”{$keywords}\” />
“);
// THE END
}

Simply call that function from the header part of your index page, and this should make web robots’ life easier 😉

Upgrade to Dapper Drake

Today I decided to updgrade my Ubuntu 5.04 System (Breezy) to the latest version, i.e. Ubuntu 6.06 (Dapper Drake). After some 764Mb of new packages, some (un-happy) removals, some installations, and some error saying that the upgrade process has been stopped due to an unforeseen error (huh!), I could manually reboot my system into its new version!

I’m a big supporter of FVWM, and use it daily instead of Gnome, which I find too slow, as I use aTerm for the same reason and conky for monitoring my system. How big was my surprise too see just after logging in a pink conky, black on black window titles, and aterm refusing to start due to some color error.

After some debugging, here is what I found out:

When starting aterm, I got this error:

aterm: can't load color black

followed by identical output for a bunch of various colors. I suspected the same happens with conky and FVWM, which cannot extrapolate HEX colors from these color names.

The solution was to modify the line in the /etc/X11/xorg.conf file which define the path to the rgb color file (rgb.txt). After the upgrade, it has simply moved from some /usr/X11.../lib/... location to /etc/X11/rgb.txt.

Simply putting

RgbPath ="/etc/X11/rgb"

in the Xorg config file did the trick (don’t type the .txt!!!).