Category Archives: Linux

Mouse button mapping in Xorg.conf

I purchased a Logitech G400 mouse to temporarily replace my Logitech MX Anywhere mouse, which I forgot at home. I wanted to use the top button for pasting instead of the scroll wheel button, which I feel is too hard to press.

This command solves the problem, by swapping the functions of button 2 (the scrollwheel button) and 10 (the top button):

$ xmodmap -e "pointer = 1 10 3 4 5 6 7 8 9 2"

The trick is that I want it done automatically when I use the G400.

My Debian Wheezy installation didn’t have a xorg.conf file, but there is nowadays an option to put specific conf snippets in /etc/X11/xorg.conf.d/*.conf:

$ mkdir /etc/X11/xorg.conf.d
$ vi /etc/X11/xorg.conf.d/LogitechG400.conf

There are a few directives in the InputClass section that can match device attributes. I used MatchProduct and MatchIsPointer (to be safe). You can just as well use MatchUSBID, I guess. These are the contents of my /etc/X11/xorg.conf-d/LogitechG400.conf file:

Section "InputClass"
Identifier "evdev mouse"
MatchProduct "Logitech Gaming Mouse G400"
MatchIsPointer "true"
Option "ButtonMapping" "1 10 3 4 5 6 7 8 9 2"
EndSection

The ButtonMapping option swaps the function of button 2 (the scrollwheel button) and 10 (the top button).

Now I can paste using the top button with the G400 mouse.

 

DVD::rip not ripping your subtitles?

There is a longstanding bug in the DVD::rip package that prevents it from ripping the subtitles if you are ripping from a directory instead of a mounted DVD.

This patch works for me:

+++ Project.pm 2012-02-01 11:59:58.359790393 +0100
@@ -376,6 +376,11 @@
         = $self->get_mount_dir_from_mtab( $dvd_device, "/etc/mtab" )
         || $self->get_mount_dir_from_mtab( $dvd_device, "/etc/fstab" );

+    # If no mount point was found, assume that it is an image dir
+    if(!$dvd_mount_point) {
+        $dvd_mount_point = $dvd_device;
+    }
+
    return $dvd_mount_point;
 }

 

 

convmvfs to the rescue

I had a hard drive with a huge amount of files that was previously connected to my old Linksys NSLU2. For some reason, all the filenames were encoded in the cp437 codepage, and when I mounted the ext3 volume on my Debian Linux box, the filenames were all messed up. I wanted to mirror the drive without changing anything on it, so I mounted it read-only.

How to solve the file name issue? Enter convmvfs. It is a nice filesystem-in-userspace hack that mirrors an entire file system while converting the file names from one system to another.

$ apt-get install fuse-convmvfs
$ mount /dev/sdb1 /mnt/hugedrive -o ro
$ mkdir /home/linus/myfsys
$ convmvfs /home/linus/myfsys -o srcdir=/mnt/hugedrive,icharset=cp437,ocharset=utf8

Tada! Now I could browse the entire converted filesystem in /home/linus/myfsys, and backup all the files with correct file names.