Hey Nowaker,
thanks for your wonderful program! It works like a charm, if you want to accelerate the mouse wheel!
Here is what I did to get your program killed and executed automatically, when the mouse is plugged in. Create the file /etc/udev/rules.d/xwheeldoubler as root and paste this content:
Code:
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0040", RUN+="/home/YOUR-NAME/bin/xwheeldoubler.sh /dev/input/%k &"
Change the vendor id and product id appropriately to your mouse. Get the info with
while the mouse is attached.
Create the file /home/YOUR-NAME/bin/xwheeldoubler.sh, chmod 755 and paste the following:
Code:
#!/bin/bash
# Desktop user
USERNAME="YOUR-NAME"
# Display to operate on
export DISPLAY=":0.0"
if [ "$1" == "/dev/input/event9" ]; then
if [ -c "$1" ]; then
if [ -r "/var/run/gdm" ]; then
export XAUTHORITY="`ls /var/run/gdm/*/database|grep auth-for-$USERNAME-`"
fi
/home/$USERNAME/bin/xwheeldoubler $1 5 &
else
killall xwheeldoubler;
fi
fi
Remember to change YOUR-NAME to your desktop username and to change event9. The right eventX for your mouse can be seen in /dev/input/by-id or /dev/input/by-path. Copy the xwheeldoubler binary to the folder /home/YOUR-NAME/bin. The multiply factor here is 5. Change it, if you want. The XAUTHORITY variable is necessary for xwheeldoubler to talk to your X server.
I like Linux
By the way: if you have a notebook with touchpad and you want to accelerate this, too, you can put the following in /etc/X11/xorg.conf:
Code:
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "synaptics"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
# accelerate vertical scrolling (default: 25)
Option "VertScrollDelta" "6"
EndSection
It depends on your xorg.conf, if you have to modify you existing InputDevice section, or if you have to add a new one. For Firefox, you can also change the wheel sensitivity, by typing about:config as address and look for the key mousewheel.withnokey.sysnumlines. Set it to false and modify mousewheel.withnokey.numlines. I changed it from 6 to 3, as otherwise Firefox would scroll too fast.
Originally Posted by
Nowaker
Code:
sudo chmod +r /dev/input/event2; xwheeldoubler /dev/input/event2 3 &
/dev/input/event2 - your mouse
3 - how many times faster
AFAIR, libxtst6 package is needed (libxtst-dev for compiling).
Compiled version for amd64 in attachment. The source code below.
Code:
gcc -lXtst xwheeldoubler.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <linux/input.h>
#include <sys/types.h>
#include <fcntl.h>
#include <X11/extensions/XTest.h>
Display *dpy;
int file;
void cleanup()
{
if(file) {
close(file);
}
if(dpy) {
XCloseDisplay(dpy);
}
}
int main(int argc, const char** argv)
{
if(argc < 3) {
printf("Usage: %s <event_device> <how_many_times_faster>\n", argv[0]);
return 1;
}
atexit(cleanup);
if((file = open(argv[1], O_RDONLY)) <= 0) {
perror("open");
return 2;
}
struct input_event event;
if ((dpy = XOpenDisplay(NULL)) == NULL) {
fprintf(stderr, "Can't open display\n");
return 3;
}
int times = atoi(argv[2]) - 1;
size_t n;
while((n = read(file, &event, sizeof(struct input_event)))>0) {
if(event.type == 0x02 && event.code == 0x08) {
if(event.value > 0) {
int i = 0;
for (; i < times; i++) {
XTestFakeButtonEvent(dpy, 4, True, CurrentTime);
XTestFakeButtonEvent(dpy, 4, False, CurrentTime);
}
} else {
int i = 0;
for (; i < times; i++) {
XTestFakeButtonEvent(dpy, 5, True, CurrentTime);
XTestFakeButtonEvent(dpy, 5, False, CurrentTime);
}
}
XFlush(dpy);
}
}
return 0;
}
Known bugs: 100% cpu after pulling in/out any USB device. Feel free to fix it. ;-]
Source code licensed under GNU GPL v3.
Bookmarks