This blog has moved! Redirecting...
You should be automatically redirected. If not, visit http://scrolls.mafgani.net/ and update your bookmarks.

Saturday, August 27, 2005

Turn on 800DPI mode for the Logitech MX-510 Mouse

5 easy steps:

1. Get and install the Logitech Applet from here or directly from here

2. Install the poper udev rules:
Create a file logitech-mice.rules under /etc/udev/rules.d/ with the following contents:


------------------------------------------
[darkknight@darkworld rules.d]$ cat logitech-mice.rules
BUS="usb", SYSFS{idVendor}="046d", SYSFS{idProduct}="c00e", PROGRAM="/usr/local/bin/logitech_applet -e -s 800"
BUS="usb", SYSFS{idVendor}="046d", SYSFS{idProduct}="c00f", PROGRAM="/usr/local/bin/logitech_applet -e -s 800"
BUS="usb", SYSFS{idVendor}="046d", SYSFS{idProduct}="c012", PROGRAM="/usr/local/bin/logitech_applet -e -s 800"
BUS="usb", SYSFS{idVendor}="046d", SYSFS{idProduct}="c024", PROGRAM="/usr/local/bin/logitech_applet -e -s 800"
BUS="usb", SYSFS{idVendor}="046d", SYSFS{idProduct}="c01b", PROGRAM="/usr/local/bin/logitech_applet -e -s 800"
BUS="usb", SYSFS{idVendor}="046d", SYSFS{idProduct}="c025", PROGRAM="/usr/local/bin/logitech_applet -e -s 800"
BUS="usb", SYSFS{idVendor}="046d", SYSFS{idProduct}="c01d", PROGRAM="/usr/local/bin/logitech_applet -e -s 800"
BUS="usb", SYSFS{idVendor}="046d", SYSFS{idProduct}="c031", PROGRAM="/usr/local/bin/logitech_applet -e -s 800"
------------------------------------------


Change the file permissions:


------------------------------------------
[darkknight@darkworld rules.d]$ sudo chown root.root logitech-mice.rules
[darkknight@darkworld rules.d]$ sudo chmod 644 logitech-mice.rules && ls -l
total 24
-rw-r--r-- 1 root root 146 Apr 13 20:30 10-wacom.rules
-rw-r--r-- 1 root root 7406 May 21 05:45 50-udev.rules
-rw-r--r-- 1 root root 888 Sep 6 23:12 logitech-mice.rules
------------------------------------------


3. Modify /etc/X11/xorg.conf as follows to support the thumb buttons:


------------------------------------------
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "ExplorerPS/2"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "6 7"
Option "Buttons" "7"
Option "Emulate3Buttons" "no"
EndSection
------------------------------------------


4. Create a script xmouse.sh under /etc/X11/xinit/xinitrc.d with the following contents:


------------------------------------------
[darkknight@darkworld xinitrc.d]$ cat xmouse.sh
#!/bin/bash

/usr/X11R6/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"
------------------------------------------


This ensures that the scrolling funtion is correctly assigned to the wheel and not to the thumb buttons.

Make sure that the file permissions are correct:


------------------------------------------
[darkknight@darkworld xinitrc.d]$ sudo chmod 755 xmouse.sh && ls -l
total 16
-rwxr-xr-x 1 root root 1579 Apr 11 13:43 xinput.sh
-rwxr-xr-x 1 root root 81 Sep 2 17:36 xmbind.sh
-rwxr-xr-x 1 root root 66 Sep 6 23:41 xmouse.sh
------------------------------------------


5. Reboot (Or simply unplug/re-plug mouse and restart X)

Happy surfing! Got the udev rules from the Ubuntu Forum (modified the PROGRAM line to use logitech_applet instead of lmctl).

Edit [July 30, 2007]:
It has been a while since the steps above were posted. The syntax of UDEV rules have changed much since then. The updated rule is (for my MX-510):

$ cat /etc/udev/rules.d/60-logitech-mouse.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c01d", RUN+="/usr/local/bin/logitech_applet -e -s 800"


Device details necessary for writing UDEV rules can be discovered using (substitute /dev/input/mouse1 with path to device of interest):

# udevinfo -a -p $(udevinfo -q path -n /dev/input/mouse1)

Thursday, August 25, 2005

MATLAB 7 SP2 on FC4 (x86_64)

The installer will not run on a default install. To get that working, I needed to install the xorg-x11-deprecated-libs.x86_64 package. It appears to contain some libraries needed by the graphical installer. Once installed, the 64bit version spits out the following error (the 32bit install is fine):


------------------------------------------
*** glibc detected *** malloc(): memory corruption: 0x0000000000598840 ***
------------------------------------------


The fix is:

------------------------------------------
$ LD_ASSUME_KERNEL=2.4.1
$ export LD_ASSUME_KERNEL
------------------------------------------


It's best to put these lines at the top of $MATLAB/bin/.matlab7rc.sh
(where $MATLAB is the installation directory).

Got this little hint from the MATLAB Support site.

Custom Keybinding (GNOME)

This is useful for multimedia keyboards that aren't automatically recognized. Also useful when you want actions other that those offered in "gnome-keybinding-properties". The first step is to check if the buttons are recognized at all. This can be accomplised by running "xev"

$ xev


Once the little window pops up, press any of the buttons and see if you get an output like the following:


---------------------------------------------------------------------------------------------
KeyPress event, serial 29, synthetic NO, window 0x3c00001,
root 0xd6, subw 0x0, time 2073408, (1033,644), root:(1051,745),
state 0x0, keycode 231 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 29, synthetic NO, window 0x3c00001,
root 0xd6, subw 0x0, time 2073529, (1033,644), root:(1051,745),
state 0x0, keycode 231 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
---------------------------------------------------------------------------------------------


If you do get the output, the important thing to note is the keycode (keycode 231 here). Once you have the keycode for a key, you need to define a Key Symbol for it. To do this, you need a xmodmap file. You can get a copy of it using:


---------------------------------------------------------------------------------------------
$ xmodmap -pke > ~/.xmodmaprc
---------------------------------------------------------------------------------------------


Once the current map is dumped, open the file for editing and locate the required keycode:


---------------------------------------------------------------------------------------------
$ vi ~/.xmodmaprc
[snip]
keycode 231 =
[snip]
---------------------------------------------------------------------------------------------


As we can see there is no symbol associated with the keycode 231 yet. To get a list of available symbols, look at /usr/X11R6/lib/X11/XKeysymDB. Since the button is marked as Refresh, we can use XF86Refresh as a suitable symbol:


---------------------------------------------------------------------------------------------
[snip]
keycode 231 = XF86Refresh
[snip]
---------------------------------------------------------------------------------------------


Once all the required keys have been set, save the file.

To make the new map take effect (in GNOME):


---------------------------------------------------------------------------------------------
$ gconftool-2 --set "/desktop/gnome/peripherals/keyboard/general/known_file_list" --type list --list-type string "[.xmodmaprc]"

$ gconftool-2 --set "/desktop/gnome/peripherals/keyboard/general/update_handlers" --type list --list-type string "[.xmodmaprc]"
---------------------------------------------------------------------------------------------


At this point you probably need to logout and log back in.

Now, for the case where xev doesn't already detect the key. Start by tailing the /var/log/messeges file:


---------------------------------------------------------------------------------------------
$ sudo tail -f /var/log/messages
---------------------------------------------------------------------------------------------


The last lines of the file will be displayed. Now, press the desired key. Now, you should see something like


---------------------------------------------------------------------------------------------
Aug 27 13:55:58 darkworld kernel: atkbd.c: Unknown key pressed (translated set 2, code 0x96 on isa0060/serio0).
Aug 27 13:55:58 darkworld kernel: atkbd.c: Use 'setkeycodes e016 <keycode>' to make it known.
Aug 27 13:55:58 darkworld kernel: atkbd.c: Unknown key released (translated set 2, code 0x96 on isa0060/serio0).
Aug 27 13:55:58 darkworld kernel: atkbd.c: Use 'setkeycodes e016 <keycode>' to make it known.
---------------------------------------------------------------------------------------------


So, as suggested, we make it known by:


---------------------------------------------------------------------------------------------
$ setkeycodes e016 187
---------------------------------------------------------------------------------------------


I chose 187 since it doesn't appear to be used by any key yet. Once all the keycodes have been set, repeat as before to assign the key symbols.

[Edit (Sept. 8, 2005)]
It seems that there is a better way to choose the kernel keycode. We can run getkeycodes to see which keycodes are currently in use. We can use any keycode between 84 and 255 that is not already used.


---------------------------------------------------------------------------------------------
$ getkeycodes
Plain scancodes xx (hex) versus keycodes (dec)
for 1-83 (0x01-0x53) scancode equals keycode

0x50: 80 81 82 83 99 0 86 87
0x58: 88 117 0 0 95 183 184 185
0x60: 0 0 0 0 0 0 0 0
0x68: 0 0 0 0 0 0 0 0
0x70: 93 0 0 89 0 0 85 91
0x78: 90 92 0 94 0 124 121 0

Escaped scancodes e0 xx (hex)

e0 00: 0 195 196 197 198 0 0 0
e0 08: 0 0 0 0 0 0 0 0
e0 10: 165 0 0 0 0 0 0 0
e0 18: 0 163 0 0 96 97 0 0
e0 20: 113 140 164 0 166 0 0 0
e0 28: 0 0 255 0 0 0 114 0
e0 30: 115 0 150 0 0 98 255 99
e0 38: 100 0 0 0 0 0 0 0
e0 40: 0 0 0 0 0 119 119 102
e0 48: 103 104 0 105 112 106 118 107
e0 50: 108 109 110 111 0 0 0 0
e0 58: 0 0 0 125 126 127 116 142
e0 60: 0 0 0 143 0 217 156 173
e0 68: 128 159 158 157 155 226 0 112
e0 70: 0 0 0 0 0 0 0 0
e0 78: 0 0 0 0 0 0 0 0

---------------------------------------------------------------------------------------------


It also seems we need to restore the kernel keycode mapping after every reboot. This is easily accomplished by having the required commands in /etc/rc.local:


---------------------------------------------------------------------------------------------
[darkknight@darkworld ~]$ cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

setkeycodes e016 187 e015 188 e014 189 e013 190 e005 191
e01e 192 e009 193 e00b 202 e008 194 e018 199
e00a 200 e017 201 e03b 203 e03c 204 e03d 205
e03e 206 e03f 207 e040 208 e041 211 e042 210
e043 212 e023 213 e057 214 e058 215 e064 216
[darkknight@darkworld ~]$
---------------------------------------------------------------------------------------------



The kernel keycodes are different from the keycodes used by X. So, we need to run xev again to get the keycodes (as seen by X) of the newly found keys.

Got the hints from here.
[End Edit]

Now that we have KeySymbols, what do we do with them? Open up gconf-editor and browse to the key /apps/metacity/global_keybindings. There, choose any of the run_command_* keys marked as disabled and change the value to the desired KeySymbol (e.g. XF86AudioPrev). Then navigate to the key /apps/metacity/keybinding_commands and find the command_* key with the same number as the run_command_*. Change the value of the key to whatever command you wish to be performed when the Previous key is pressed. If you happen to run out of run_command_* and command_* key pairs, simply create new pairs from the right click menu.

Wednesday, August 24, 2005

HTML Redirect

Ever since I started this blog, I've been looking at some HTML code fragments. Here's one to redirect pages:

<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/index.html">


Right now I'm using this to redirect visitors from my pandora home page to here. Got this fragment from this page.

Importing Firefox passwords from another profile

It's a lot simpler than I thought it would be - simply copy key3.db and signons.txt to the new profile and make sure they are writable.

Tuesday, August 23, 2005

NTFS/FAT32 Volume Labels on GNOME computer://

By default, GNOME labels the drives by their sizes. The following *fdi scipt for HAL makes is possible to automount the volumes discovered at boot-time. The volumes are mounted and labeled according to their Volume Label under /media. So, here it is:

---------------------------------------------------------------------------------------------
[darkknight@darkworld ~]$ cat storage-fixed.fdi
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->

<deviceinfo version="0.2">
<device>
<match key="volume.partition.msdos_part_table_type" int="0x07">
<merge key="volume.policy.should_mount" type="bool">true</merge>
<merge key="volume.policy.mount_option.pamconsole" type="bool">true</merge>
<merge key="volume.policy.mount_option.noauto" type="bool">false</merge>
<merge key="volume.policy.mount_option.exec" type="bool">false</merge>
<merge key="volume.policy.mount_option.umask=022" type="bool">true</merge>
<merge key="volume.policy.mount_option.ro" type="bool">true</merge>
</match>
</device>

<device>
<match key="volume.partition.msdos_part_table_type" int="0x0b">
<merge key="volume.policy.should_mount" type="bool">true</merge>
<merge key="volume.policy.mount_option.pamconsole" type="bool">true</merge>
<merge key="volume.policy.mount_option.noauto" type="bool">false</merge>
<merge key="volume.policy.mount_option.exec" type="bool">true</merge>
<merge key="volume.policy.mount_option.umask=000" type="bool">true</merge>
<merge key="volume.policy.mount_option.rw" type="bool">true</merge>
</match>
</device>

<device>
<match key="storage.hotpluggable" bool="false">
<match key="storage.removable" bool="false">
<merge key="storage.policy.should_mount" type="bool">true</merge>
</match>
</match>
</device>
</deviceinfo>
[darkknight@darkworld ~]$
---------------------------------------------------------------------------------------------

The file should be placed under /usr/share/hal/fdi/policy/10osvendor/

I know for sure that the NTFS part works, and someone with FAT32 volumes told me that FAT32 automount works as well.

It is also available from here.

Audigy 2 ZS on FC4

I've finally got a setup that sounds just as good as it does on Windows. I've tested the surround system with a DVD and so far it sounds pretty good. I think the trouble was that there wasn't any signal generator to let me balance the speakers properly. But today I discovered that there is an alsa subdirectory under /usr/share/sounds that contains a noise file. Playing that in a loop:

$ while [ 1 ]; do aplay /usr/share/sounds/alsa/Noise.wav; done


I finally managed to get that elusive speaker balance through alsamixer. Now, all that's missing is CMSS3D :)

This site might be useful.

Sunday, August 21, 2005

Prosper (TeX) Tutorials

Found a couple of prosper tutorials that were particularly helpful:

VPN from Linux (x86_64)

The Cisco VPN client doesn't seem to compile on the 64bit architecture. Well, open source to the rescue .. behold VPNC. Since the Cisco profile files are no good, I needed to decrypt the group password - which was a piece of cake thanks to the password decryptor on the site. They say it's done through the command:

# ltrace -i ./vpnclient connect ... 2>&1 | fgrep 805ac57


I'll try it for myself sometime.

Saturday, August 20, 2005

Changing/Suppressing the "References" title from Bibliographies

The command needed is:

\renewcommand\refname{New title}

This is particularly useful for slides. Found this little trick here.

Friday, August 19, 2005

WebCollage

It seems FC4 has dropped the WebCollage screensaver. So I had to install it myself. It's quite easy actually: just save the file to /usr/libexec/xscreensaver/ and you're done (almost). I think it must also be owned by root and be executable by all. It's a pretty cool screensaver - you never know what you'll find ;)

Actually, the main reason I went hunting for it was to track down Driftnet. It's a cool tool that essentially sniffs out images from the local network for you to see :D. Fortunately, it was available from the Dries rpm repo.

GPLFlash 2


Ok .. built and installed GPLFlash .. at least Firefox thinks it's installed. Time to give it a try: well .. seems like StarTrek.com still won't work .. guess it won't settle for anything less than Flash 6 :(

GPLFlash

Ever since I installed FC4 64-bit, plugins have been a constant pain is the a**. I remembered seeing a reference to GPLFlash some time back .. so I went and grabbed the source tarball .. unfortunately it requires too many *-devel packages and I can't afford the disk space. So, rpm.pbone.net to the rescue. I managed to find a x86_64 rpm for SuSE 9.3 - so I'm gonna give that a go. Seems like it needs libresmgr which is not in any of the FC repos I use. So, I also needed to borrow that from SuSE.

It's now that I fully appreciate the new localinstall option of yum. Point to to a local rpm and it sorts out dependencies from the actives repos .. just too cool..

Ok .. this isn't going anywhere .. the dependencies are too SuSE centric .. guess I'll just have to get the *-devel packages and make do with the source tarball..

First blog

Well .. I've been giving this some thought .. the main motivation behind starting this thing is the fact that I seem to forget a lot of the stuff that I found out digging through the web, linux man pages etc.. let this be my (somewhat) permanent record of the things I do .. to save myself the trouble of backtracking through memory lane...

I guess this will be mostly computer related .. Linux, TeX, etc..