Working the MX Revolution on Linux
Update 7/18/2010
In the past I always shut down my machine, never let it got to sleep or hibernate, so I never dealt with the issue of what happens to the MX when you come back from one of those state(hint: not what you'd like). If your wheel resets to free spin after waking up, drop the below script in /etc/pm/sleep.d, changing the location of revoco if necessary:
After getting everything setup just the way I liked it, I noticed one thing that would bother me if it wasn't corrected. Few of my extra mouse buttons worked. I have a Logitech MX Revolution and in Windows I used the thumb wheel as my volume control, and the search button was play/pause. However here they were dead except the search button which helpfully popped up an error message on every press. Also I noticed that the scroll wheel was set so that if you click the wheel, it alternates between click and free spin. This robbed me of the middle click functionality that I use in my browsing to open links in new tabs and to also close open tabs. It took some time, but after wading through numerous blogs and message boards, I was able to put it all together and get my mouse working correctly.
Overview
Since i'm on Mint, these instructions apply to it and will probably work on most distros with few modifications(yum instead of apt-get or aptitude, etc). On older distros you may have to install the evdev driver, but most come with it by default now. If you're using an older distro, and you can't get the following to work, skip down to the bottom and see if the extra setup helps. You'll also be needing revoco, a utility that manipulates the Revolution's wheel spin setting(free spin, click-to-click), and xbindkeys, a utility to map commands to mouse buttons.
Your package names may vary, so try searching the repos for the exact name of the package to install. First lets get xbindkeys, which does the actual button to command mapping:
cc -Os -DVERSION=\"0.5\" -Wall -c -o revoco.o revoco.c
cc -s revoco.o -o revoco
Now that everything is installed, we can start setting up the mouse. For me the configuration was minimal, I only setup 4 buttons. This involves editing Xorg.conf(You can skip this step if you didn't have to install evdev), setting the wheel scroll state(Again, you can skip this step if you don't care) and finally setting up binds for the keys. I copied my revoco binary to the /usr/bin directory so I didn't have to fool around with cd'ing to the directory and I can just call it from wherever I am. You can do the same, otherwise you'll have to cd to the directory first. Configure revoco to your liking, for me it was setting it to click-to-click(people not putting it in /usr/bin, use "./revoco":
revoco click
"amixer set Master toggle"
b:17
#Middle button forward(volume up)
"amixer set Master 2+"
b:13
#Middle button click(mute)
"amixer set Master 2-"
b:15
#Play/Pause button
"rhythmbox-client --play-pause"
c:225
Legacy
Certain older distros might not have the evdev driver installed by default and in turn would need to edit Xorg.conf to use the new driver. If you're using an older version, and the above alone don't get it working, try the following. First let's check if we have the evdev driver installed.
I: Bus=0003 Vendor=046d Product=c51a Version=0111
N: Name="Logitech USB Receiver"
P: Phys=usb-0000:00:0b.0-6.3/input0
S: Sysfs=/devices/pci0000:00/0000:00:0b.0/usb2/2-6/2-6.3/2-6.3:1.0/input/input5
U: Uniq=
H: Handlers=mouse1 event5
B: EV=17
B: KEY=ffff0000 0 0 0 0
B: REL=143
B: MSC=10
# generated from default
#Identifier "Mouse0"
#Driver "mouse"
#Option "Protocol" "auto"
#Option "Device" "/dev/psaux"
#Option "Emulate3Buttons" "no"
#Option "ZAxisMapping" "4 5"
#EndSection
Section "InputDevice"
Identifier "MX Revolution" #This can be whatever you want
Driver "evdev" #The driver we downloaded
Option "Phys" "usb-*/input0" #The above device info
Option "CorePointer"
EndSection
Identifier "Default Layout"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
# InputDevice "Mouse0" "CorePointer"
InputDevice "MX Revolution" "CorePointer" #Input the "Identifier" from the InputDevice section
EndSection
Etc.
I can only say these are the numbers for the MX Revolution, but even then i've seen some tutorials list out different numbers than what i've got. If you're not getting the results you expect with a button you setup, run "xev" from the console and press each button, paying attention to the output. You're looking for ButtonPress or ButtonRelease events, and inside them the "button" property which indicates the button number that you'll use when assigning binds:
brandon@minty ~ $ xev
ButtonPress event, serial 33, synthetic NO, window 0x3600001,
root 0x13c, subw 0x0, time 8383250, (82,82), root:(2045,583),
state 0x10, button 2, same_screen YES
Left button-------------3
Middle wheel click------2
Middle wheel push-------4
Middle wheel pull-------5
Middle wheel left-------6
Middle wheel right------7
Thumb button back-------8
Thumb button forward----9
Thumb wheel push--------13
Thumb wheel pull--------15
Thumb wheel click-------17
Search button-----------keycode 225
mod_security part deux
I had another runin with an overzealous mod_sec rule today. This time I was testing some new tags on my comment form, one of which is a code block. When inserting any perl or python code into the block, and submitting it, mod_security flags it as an attempted command injection. When trying to post the following(either "python" or "perl"):
<div>Python Code</div>
[data ";\x22>python"]
...p(?:asswd|ython|erl|ing|s)...
lab.reasonman.com
I've gotten a large amount of the new site done, and it's live over at lab.reasonman.com. Right now it's only the blog system. Downloads and Login will give you a 404/not found. But feel free to comment to your hearts content. Soon that will be making it's way over to the main page, replacing the current layout/system. Also feel free to comment over there about things mentioned here until the switch is final.
On PHP
I've been playing around with PHP for the first time in a very long time. The first time I tried it, for whatever reason I just really didn't like it. When it came time to put together this site, I thought about what languages I could use, and narrowed it down between ASP.NET and PHP. I took another look at PHP but my bias clouded my judgement so I discounted it because it didn't "feel" like C#. Then I figured that because I already know C#, using it with ASP.NET made sense, and it did. It took quite a while to get the site live because I was learning as I was building. Mistakes were made, tears were shed and words were yelled. Overall, I'm happy with what i've cobbled together. But it feels like it's just that, cobbled. Discounting all the negatives, I learned alot about the web side of development, and have taken a liking to it. I've learned alot about security, how clients request and cache information, and a load of other things.

