Page 3 of 7 FirstFirst 12345 ... LastLast
Results 21 to 30 of 61

Thread: HOWTO: General mouse customization, including double click

  1. #21
    Join Date
    Jun 2006
    Location
    a polluted desert
    Beans
    101
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: HOWTO: General mouse customization, including double click

    Thank you. I didn't know that the key entries ('keydownn Alt_R' 'keydown Control_R' etc) had to be monospaced.

  2. #22
    Join Date
    Jan 2007
    Beans
    6

    Re: HOWTO: General mouse customization, including double click

    this doesent work for me

  3. #23
    Join Date
    Dec 2006
    Beans
    678

    Re: HOWTO: General mouse customization, including double click

    Quote Originally Posted by Maki_doda View Post
    this doesent work for me
    If you provide a little detail about your hardware and what you've tried, I can try to provide additional help.

  4. #24
    Join Date
    Dec 2006
    Beans
    678

    Re: HOWTO: General mouse customization, including double click

    For the curious, I've modified the original post to include what appears to be the most-requested behavior, forward & back buttons, as a quick fix in xorg.conf, as this:
    edit /etc/X11/xorg.conf in the mouse section, and add the following two lines:
    Code:
    Option "Buttons" "7"
    Option "ButtonMapping" "1 2 3 6 7"
    Make sure to backup the file first, and restart X to have the effect take place.

    This won't work for all mice, and only works for a specific behavior, but may help out some people who want a quick fix.

  5. #25
    Join Date
    Dec 2006
    Beans
    678

    Re: HOWTO: General mouse customization, including double click

    Another update - see this thread for those interested in application-specific mouse (or keyboard) settings: http://www.ubuntuforums.org/showthread.php?p=2089118 .

  6. #26
    Join Date
    Dec 2006
    Beans
    678

    Re: HOWTO: General mouse customization, including double click

    One more (final?) update, in case someone else has had the frustration I have with using an external mouse left-handed and therefore having a messed up built-in laptop mouse when the external mouse is disconnected (or otherwise wants different behavior when a mouse is/isn't connected): see this thread: http://www.ubuntuforums.org/showthread.php?t=350464.

  7. #27
    Join Date
    Feb 2007
    Beans
    6

    Re: HOWTO: General mouse customization, including double click

    Thanks for the post tweedledee, this worked great!

  8. #28
    Join Date
    Dec 2006
    Beans
    13

    Re: HOWTO: General mouse customization, including double click

    The behavior of the double-click here was a little frustrating for me. The Logitech Windows drivers that I am used to would double-click on button press and not button release. I found that I missed the double-click a lot because I had moved the mouse off the icon by the time the specified button was released.

    I found an easy way to fix this. Simply replace this:

    Code:
    "/usr/bin/xte 'mouseclick 1' 'mouseclick 1' &"
    b:Y + Release
    With this:

    Code:
    "/usr/bin/xte 'mouseup Y' 'mouseclick 1' 'mouseclick 1' &"
    b:Y
    Replace "Y" with the button number you are mapping. This sends a button release event which allows the double-click to pass through. I find the double-clicking to seem a lot more responsive now since the action initiates right when you press the button.

  9. #29
    Join Date
    Dec 2006
    Beans
    678

    Re: HOWTO: General mouse customization, including double click

    Quote Originally Posted by Demogorge View Post
    The behavior of the double-click here was a little frustrating for me. The Logitech Windows drivers that I am used to would double-click on button press and not button release. I found that I missed the double-click a lot because I had moved the mouse off the icon by the time the specified button was released.
    I've noted your tweak, thanks for the feedback.

  10. #30
    Join Date
    Feb 2007
    Beans
    37

    Re: HOWTO: General mouse customization, including double click

    I liked this howto because it allowed me to get the back/forward buttons working in firefox AND nautilus. However, I missed imwheel's ability to specify different key events for different applications/windows. So I decided to write my own hack to solve this problem.

    First I wrote a little program to query window information. If anyone is interested and know of a free file storage location I'll upload the program.

    For the curious/ambitious, the source is posted at the end. The name of the program is 'qawn' (Query Active Window Name).

    So this is what my .xbindkeysrc looks like:
    Code:
    # Back Button
    "/usr/local/bin/mouse-back-button.sh"
       b:8
    # Forward Button
    "/usr/local/bin/mouse-forward-button.sh"
       b:9
    And here is the mouse-back-button.sh script:
    Code:
    #!/bin/bash
    #
    # generate key events based on window criteria
    
    # Control_L + Page_Up
    qawn -p | egrep -i "gnome-terminal"
    if [ $? -eq 0 ]; then
    	/usr/bin/xvkbd -xsendevent -text "\[Control_L]\[Page_Up]" &
    	exit 0
    fi
    
    # Default: Alt_L + Left
    /usr/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]" &
    exit 0
    The mouse-forward-button.sh looks identical except for the key events that it generates. So now when I want to bind the back/forward buttons for a new application I just have to edit these two scripts. It's pretty nifty because I can have my cake (firefox + nautilus) and eat it too (gnome-terminal et al).



    Here is the source:
    Code:
    #include <string.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <X11/Xlib.h>
    #include <X11/Xutil.h>
    
    void usage(char *progname)
    {
    	char *shortname = rindex(progname, '/');
    	if (!shortname) {
    		shortname = progname;
    	}
    	else {
    		shortname++;
    	}
    	printf("%s <options>\n", shortname);
    	printf("  -p  --process-name   Query for the active window's process name\n");
    	printf("  -c  --process-class  Query for the active window's process class\n");
    	printf("  -n  --name           Query for the active window's name (title)\n");
    }
    
    
    typedef enum {
    	PROCESS_NAME,
    	PROCESS_CLASS,
    	NAME,
    	UNKNOWN
    } QUERY_TYPE;
    
    int main(int argc, char **argv)
    {
    	if (argc != 2) {
    		usage(argv[0]);
    		exit(1);
    	}
    
    	QUERY_TYPE qt = UNKNOWN;
    	if (!strcmp(argv[1], "--process-name") || !strcmp(argv[1], "-p")) {
    		qt = PROCESS_NAME;
    	}
    	else if (!strcmp(argv[1], "--process-class") || !strcmp(argv[1], "-c")) {
    		qt = PROCESS_CLASS;
    	}
    	else if (!strcmp(argv[1], "--name") || !strcmp(argv[1], "-n")) {
    		qt = NAME;
    	}
    
    	if (qt == UNKNOWN) {
    		usage(argv[0]);
    		exit(1);
    	}
    
    	Display *display;
    	char *envDisplay = getenv("DISPLAY");
    
    	if (!envDisplay) {
    		fprintf(stderr, "Unable to query DISPLAY environment variable!\n");
    		exit(1);
    	}
    	display = XOpenDisplay(envDisplay);
    	if (!display) {
    		fprintf(stderr, "Unable to open display (%s)!\n", envDisplay);
    		exit(1);
    	}
    
    	Window w;
    	int rtr;
    	XGetInputFocus(display, &w, &rtr);
    
    	if (qt == PROCESS_NAME || qt == PROCESS_CLASS) {
    		XClassHint xch;
    		Status rc = XGetClassHint(display, w, &xch);
    		if (rc == BadWindow) {
    			fprintf(stderr, "XGetClassHint returned BadWindow error!\n");
    			exit(1);
    		}
    		// output what we've found
    		if (qt == PROCESS_NAME && xch.res_name) {
    			printf("%s\n", xch.res_name);
    		}
    		else if (xch.res_class) {
    			printf("%s\n", xch.res_class);
    		}
    
    		if (xch.res_name) {
    			XFree(xch.res_name);
    		}
    		if (xch.res_class) {
    			XFree(xch.res_class);
    		}
    	}
    	else if (qt == NAME) {
    		char *name;
    		Status rc = XFetchName(display, w, &name);
    		if (rc == BadWindow) {
    			fprintf(stderr, "XFetchName returned BadWindow error!\n");
    			exit(1);
    		}
    		// output what we've found
    		if (name) {
    			printf("%s\n", name);
    			XFree(name);
    		}
    	}
    	
    	// cleanup
    	XCloseDisplay(display);
    
    	return 0;
    }
    Here is the makefile:
    Code:
    all:
    	g++ main.cpp -g -o qawn `pkg-config --cflags --libs vte`
    
    clean:
    	rm -f qawn
    
    install: all
    	cp -f qawn /usr/local/bin
    
    uninstall:
    	rm -f /usr/local/bin/qawn

Page 3 of 7 FirstFirst 12345 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •