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 😉

New design in place!!!

As you can see, I’ve finished the main work about my new design. If you are new here, you can compare to the old one on the picture below:

Old site

Hope you’ll enjoy the new one 🙂