Page 1 of 6 123 ... LastLast
Results 1 to 10 of 56

Thread: Ubuntu 8.10 BTNX replacement tutorial

  1. #1
    Join Date
    Apr 2008
    Beans
    47

    Lightbulb Ubuntu 8.10 BTNX replacement tutorial

    With the release of Ubuntu 8.10, BTNX has been broken. As such, I figured I'd write up a small, hopefully as clear as possible tutorial on how to 'replace' it with a few other simple utilities.

    There have been a few others posts on this, and I've found them helpful after some head scratching. I figured I'd try to make a simple, unified post.

    So here is how I got my Logitech MX Revolution working again.

    1) Install 2 utilities: xmacroplay and xbindkeys

    Code:
    sudo apt-get install xbindkeys xmacro
    xbindkeys runs commands when certain keyboard key presses or mouse button presses are detected. xmacro is a program for playing, shocker, macros. It can be used to generate, amongst other things, keypresses in an X window

    2) Go through the (painful) button discovery process. To do this:

    a) edit the configuration file for xbindkeys

    gedit ~/.xbindkeysrc

    delete the full contents of this file and add the following lines:

    Code:
    "echo 'KeyStrPress Enter KeyStrRelease Enter' | xmacroplay :0"
    b:1
    This will echo a very simple macro to the macro player which will direct the results of said macro to the default X display. In this case, it will generate a press of the 'enter' key.

    b) launch a text editor window. We will use this to see the results of the macro running

    c) run the following command in the terminal window:

    Code:
    xbindkeys -n -v
    Note: This will likely prevent the normal functioning of whatever button you are looking for.

    d) select the text editor and start pressing mouse buttons until you get an 'enter' that will be button b:1 for your mouse. Once you find the button, reselect the terminal and Ctrl+C the process to stop it.

    Repeat the whole process for different b:#'s (i.e. b:2). Make sure to note what button codes correspond to which buttons. Also, try multi button presses if no single button generates an event. For instance on my Revo, pressing the left and right buttons together is b:3

    You should be able to find the button codes for most buttons using this process. On my mouse, the only button I couldn't find was the search button (which is handled differently by the OS for some odd reason).

    For my mouse, the list looked like this:

    Code:
    # Mappings for keys for MX Revo
    # b:1	-	left mouse button
    # b:2	-	left and right mouse button together
    # b:3 	-	right mouse button
    # b:4	-	mouse wheel up
    # b:5	-	mouse wheel down
    # b:6	-	mouse wheel left
    # b:7	-	mouse wheel right
    # b:8	-	back button
    # b:9	-	forward button
    # b:10	-	-none-
    # b:11	-	-none-
    # b:12	-	-none-
    # b:13	-	media wheel up
    # b:14	-	-none-
    # b:15	-	media wheel down
    # b:16	-	-none-
    # b:17	-	media wheel press
    this list is only for your refrence when you start binding button presses to macros. You don't need to have it anywhere in any file (but it dosen't hurt to note them as comments in the ~/.xbindkeysrc file.

    3) Figure out the Xmacro names for the keys you want to simulate

    xmacro uses special codes to represent key presses and button clicks. The simplest way to figure out what codes to use for what you want to do is by using the xmacrorec2 utility.

    To do this, start xmacrorec2 in a terminal and redirect the output to a reference file.

    Code:
    xmacrorec2 > dump.txt
    After starting xmacrorec2, press the scroll lock key to start recording actions. Then press any key or button you'd like to know the code of. When done, press scroll lock again to stop recording. Then look in the dump.txt file:

    Code:
    cat dump.txt
    You should see things like this:

    Code:
    MotionNotify 378 241
    KeyStrPress XF86AudioMute
    KeyStrRelease XF86AudioMute
    KeyStrPress XF86AudioMute
    KeyStrPress XF86AudioLowerVolume
    KeyStrRelease XF86AudioMute
    KeyStrRelease XF86AudioLowerVolume
    KeyStrPress XF86AudioLowerVolume
    KeyStrRelease XF86AudioLowerVolume
    KeyStrPress XF86AudioLowerVolume
    KeyStrPress XF86AudioRaiseVolume
    KeyStrRelease XF86AudioLowerVolume
    KeyStrRelease XF86AudioRaiseVolume
    4) Create your configuration file

    Using the button codes from step 2 and the xmacro codes from step three, form your configuration file. Use the following format:

    Code:
    # Example for a key press
    "echo 'KeyStrPress <xmacro code> KeyStrRelease <xmacro code>' | xmacroplay :0"
    <mouse button code>
    where <xmacro code> is replaced (including carrots) with the keyboard code from step three and where <mouse button code> is replaced with a button code from step two.

    Simulating mouse button presses is a bit different, but follows the same idea.

    The above example will simulate a key press followed by an immediate key release. To configure multi-key presses, simply list all the keys, first as presses, then as releases, in a list seperated by spaces.

    My final simple configuration file ended up looking like this:

    Code:
    # Mapping enter key to mousewheel right
    "echo 'KeyStrPress Return KeyStrRelease Return' | xmacroplay :0"
    b:7
    
    # Mappings for media wheel
    "echo 'KeyStrPress XF86AudioNext KeyStrRelease XF86AudioNext' | xmacroplay :0"
    b:13
    "echo 'KeyStrPress XF86AudioPrev KeyStrRelease XF86AudioPrev' | xmacroplay :0"
    b:15
    "echo 'KeyStrPress XF86AudioPlay KeyStrRelease XF86AudioPlay' | xmacroplay :0"
    b:17

    5) Test your configuration

    Once all of the above is setup, test your configuration by running:

    Code:
    xbindkeys -n -v
    in a terminal window. Leave the terminal up and let the code run and try out your mappings. When you are satisfied everything is working correctly, close the terminal window, and add a strait call to xbindkeys with no flags to your session. For gnome, this involves opening the System->Prefrences->Sessions, click on Add, then put any name (i.e: xbindkeys) and put xbindkeys in the command box (without the -n (not daemon) and -v (verbose) options), just xbindkeys. The next time you restart you system xbindkeys will run automatically.

    Please let me know if anything here is unclear. Also, feel free to post your button mappings for others to use!
    Last edited by cecilx22; November 6th, 2008 at 02:51 AM. Reason: added additional info

  2. #2
    Join Date
    Feb 2007
    Beans
    68

    Talking Re: Ubuntu 8.10 BTNX replacement tutorial

    Thanks for this, it's been very helpful since I forgot most of this after I discovered Btnx
    Wouldn't it be easier to do the button discovery using xev? It directly tells you what button you're pressing.
    I don't know if you're using it, but you could use revoco to change the click wheel behaviour to that of a normal click wheel (you can also set at which speed it switches to free spin and so)
    There're just 2 things I can't get to work properly.One of them is that I dont know how to map the search button to something else, and the other thing I never got working without Btnx and i'm not sure how to explain it properly.
    I use the compiz plugin Scale, which is similar to OS X's Expose, the problem is the key needs to remain pressed until I choose a window but if there's no "key up" event it will just loop back to Scale after I select a window, I have no idea how this was done in Btnx, so any ideas would be welcomed.

  3. #3
    Join Date
    Apr 2008
    Beans
    47

    Re: Ubuntu 8.10 BTNX replacement tutorial

    Thanks for the info. I didn't manage to discover xev. If you'd like to put up a how-to I'll incorporate it gladly.

    Also, the search button is actually mapped to the search key XF86Search. Hope that helps with that. I'm not sure what c:# that works out to, or if it's a combination.

    As far as the 'Scale' plugin, I use it too. If I map the functionality to a key press, it works fine, but to a mouse button I have the same issue you describe. I'd call it a bug in 'Scale' rather than you doing something wrong. Maybe put in a bug report?

  4. #4
    Join Date
    Feb 2007
    Beans
    68

    Re: Ubuntu 8.10 BTNX replacement tutorial

    Regarding xev, it's pretty simple, you just open up a terminal and run "xev", after that a small window appears, when you click inside the window with, let's say, the left button a bunch of text comes up in the terminal, somewhere in this text it says "Button 1" (for the left button, of course), I can't test it right now to give you an example but it's not at all hard to see, and it's a lot less painful and simple than the method you used, since xev basically asks the X server to send it events whenever anything happens to the window. Also, you can read eny event such as the window being moved, resized, typed in, etc.

    About the Search button, there's a way to change it to middle click, and I dont see why you couldn't change that to anything else, posted here -> http://ubuntuforums.org/showpost.php...37&postcount=1
    It's quite old, but I think it should work, I'll have to try it when I get home.

    And as far as the Scale plugin it worked fine in 8.04 with Btnx so i dont see why it wouldn't work now, but, of course, the how remains unanswered. I sure miss Btnx!
    Last edited by Macdelaney; November 3rd, 2008 at 04:37 PM.

  5. #5
    Join Date
    May 2008
    Beans
    98

    Re: Ubuntu 8.10 BTNX replacement tutorial

    oh thanks for this,i was just about to test and see if http://ubuntuforums.org/showpost.php...37&postcount=1 would work in intrepid.
    this guide will be a blessing when i get around to it. search button as middle click is essential for me

  6. #6
    Join Date
    Mar 2008
    Beans
    4

    Re: Ubuntu 8.10 BTNX replacement tutorial

    Thank you SO MUCH for this tutorial. Thanks for saving those with the MX Revo from doing the trial and error work

    By the way, the code for the search button is "c:0xE1" as shown by mgc8 in this post.


    Edit: Sweet! I just discovered the CompizConfig settings manager can detect the media wheel. I use it to flip the 3d cube around. If you try to change the mouse button setting for flipping left/right, you only get mouse buttons up to Button9. However, if you click the edit button next to that button, you can type in Button15/13.

    I also mapped my search button to Button2 as done in the referenced post. Now I'm back to btnx functionality. The only thing is the annoying delay in xmacroplay.
    Last edited by AJLobo; November 3rd, 2008 at 10:22 PM.

  7. #7
    Join Date
    May 2008
    Beans
    98

    Re: Ubuntu 8.10 BTNX replacement tutorial

    great discovery on the cube rotation

  8. #8
    Join Date
    Feb 2007
    Beans
    68

    Re: Ubuntu 8.10 BTNX replacement tutorial

    Great discovery in deed with the cube rotation, i'm using it for the Scale plugin.
    I still can't make the Search button thing work! The Search window keeps popping up!
    My .xbindkeysrc in its pertinent part reads

    # Mapping for Search button
    "echo 'ButtonPress 2 ButtonRelease 2' | xmacroplay :0"
    c:0xE1

    after that I run xbindkeys -n -v, and oddly it tells me that there may be another program running which captures one of the keys captured by xbindkeys, which is incredibly strange since i have nothing running.
    Any help would be much appreciated

  9. #9
    Join Date
    May 2008
    Beans
    98

    Re: Ubuntu 8.10 BTNX replacement tutorial

    to get rid of the search window popping up:
    system > prefs > keyboard shortcuts
    scroll down to the entry called 'search'
    click it and disable by pressing backspace

  10. #10
    Join Date
    Nov 2008
    Location
    France
    Beans
    1
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Ubuntu 8.10 BTNX replacement tutorial

    I've not messed with multi-key press macros. If anyone wants to clue me in on this, I'll be happy to add it.
    well actually it's very simple, i wanted to do that for the 'show-desktop' option in compiz.
    I manage to link my button10 on my logitech cordless click with this event :
    "echo 'KeyStrPress Control_L KeyStrPress Alt_L KeyStrPress d KeyStrRelease Alt_L KeyStrRelease Control_L KeyStrRelease d' | xmacroplay :0"
    b:10
    It seems that you just have to list every event one after the other ...

    anyway thank you very much for your tuto !!

Page 1 of 6 123 ... LastLast

Tags for this Thread

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
  •