[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: xmodmap FC4



Fran├žois Patte wrote:
> Bonjour,
> 
> I have laptop with a wheel for the sound volume and I tried (without
> success) to make work under fc4 using xmodmap.
> 
> First, I used xev which return: keycode=174 when I turn the wheel
> clockwise and keycode=176 for counter clockwise.
> 
> So put
> 
> keycode 176 = 0x1008FF13
> keycode 174 = 0x1008FF11
> 
> in a .xmodmaprc and run xmodmap .xmodmaprc
> 
> Now, xev returns:
> 
> KeyPress event, serial 29, synthetic NO, window 0x2e00001,
>     root 0x131, subw 0x0, time 2623843, (82,114), root:(88,526),
>     state 0x0, keycode 176 (keysym 0x1008ff13,
> XF86AudioRaiseVolume),             same_screen YES,
>     XLookupString gives 0 bytes:
>     XmbLookupString gives 0 bytes:
>     XFilterEvent returns: False
> 
> and
> 
> KeyPress event, serial 29, synthetic NO, window 0x2e00001,
>     root 0x131, subw 0x0, time 2623344, (82,114), root:(88,526),
>     state 0x0, keycode 174 (keysym 0x1008ff11,
> XF86AudioLowerVolume),             same_screen YES,
>     XLookupString gives 0 bytes:
>     XmbLookupString gives 0 bytes:
>     XFilterEvent returns: False
> 
> But nothing happens to the volume level....
> 
> What did I miss?

I don't know about xmodmap but I've had success using a small C program
to do what you want.  I'll try to attach it here...not sure if the list
will take it.  If not, and you want it, let me know and I'll send it to
your normal email.

Ed

-- 
>From 0 to "what seems to be the problem officer" in 8.3 seconds.
		-- Ad for the new VW Corrado

/*
 * Compile with
 *
 *    cc -o audio_keys -O2 -s audio_keys.c -L/usr/X11R6/lib -lX11
 */


#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>

int main(int argc, char *argv[])
{
    struct {
	int keycode;
	int modifier;
	char *action;
    } actions[] = {
	{ 174, 0, "amixer -c1 sset PCM 5%-" },		// volume down
	{ 176, 0, "amixer -c1 sset PCM 5%+" },		// volume up
	{ 160, 0, "amixer -c1 sset PCM toggle" },	// mute
	{ 162, 1, "xmms --show-main-window" },		// shift play/pause
	{ 162, 0, "xmms --play-pause" },		// play/pause
	{ 164, 0, "xmms --stop" },			// stop
	{ 144, 0, "xmms --rew" },			// rewind
	{ 153, 0, "xmms --fwd" }			// forward
    };
	    
    Display *display;
    int i;

    if ((display = XOpenDisplay(NULL)) == NULL) {
	fprintf(stderr, "Cannot open display\n");
	exit(1);
    }

    for (i = 0; i < sizeof(actions)/sizeof(actions[0]); i++)
	XGrabKey(display,
		 actions[i].keycode,
		 AnyModifier,
		 DefaultRootWindow(display),
		 False,
		 GrabModeAsync,
		 GrabModeAsync);

    for (;;) {
	XEvent e;
	XNextEvent(display, &e);

	if (e.type == KeyPress) {
	    for (i = 0; i < sizeof(actions)/sizeof(actions[0]); i++) {
		if (actions[i].keycode == e.xkey.keycode &&
		    (actions[i].modifier == 0 || (actions[i].modifier & e.xkey.state))) {
		    printf("%s\n", actions[i].action);
		    system(actions[i].action);
		    break;
		}
	    }
	}
    }
    return 0;
}

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]