Announcement

Collapse
No announcement yet.

Hokey how to

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hokey how to

    Hi,

    I finally got around to getting my hotkey working on my Microsoft keyboard. This allows me to get the Internet and Calculator buttons to work. Thought I would post this in case anyone needs it.

    Here are some of the sites that I used to get it working:
    https://help.ubuntu.com/community/MultimediaKeys
    http://linux.oneandoneis2.org/keys.htm
    https://wiki.kubuntu.org/KDEMultimediaKeys
    http://cweiske.de/howto/xmodmap/allinone.html

    I know this works on 6.06 but I don't know about later versions. I'll check when 8.04 comes out. If anyone has any ideas how to get this so that it is global without modifying to many system files, that would be great.

    ------------------------------------------------------------------------------------------------------------------
    OS: Kubuntu Dapper 6.06 LTS
    This will allow you to map special keys on a keyboard (the calculator in this case)
    to execute programs while running under KDE.

    1. In KDE:
    Code:
    xmodmap -pke
    to see all codes or:
    Code:
    sudo dumpkeys
    2. Run
    Code:
    xev
    and press the Calculator button to get keycode, here is output before modification:
    Code:
    KeyPress event, serial 28, synthetic NO, window 0x2c00001,
      root 0xa2, subw 0x0, time 1754557011, (1046,658), root:(1050,681),
      state 0x10, keycode 161 (keysym 0x10000161, (no name)), same_screen YES,
      XLookupString gives 0 bytes:
      XmbLookupString gives 0 bytes:
      XFilterEvent returns: False
    
    KeyRelease event, serial 28, synthetic NO, window 0x3000001,
      root 0xa2, subw 0x0, time 1754557011, (1046,658), root:(1050,681),
      state 0x10, keycode 161 (keysym 0x10000161, (no name)), same_screen YES,
      XLookupString gives 0 bytes:
    3. Double check to make sure that your keycode is not already mapped when using
    Code:
    xmodmap -pke
    4. Make a .Xmodmap file in your home directory and add
    Code:
    keycode 161 = Scalculator
    5. Add a line to /usr/share/X11/XKeysymDB with the name "Scalculator" and the keysym 0x10000161 (which is keycode 161)
    Mine looks like this:
    Code:
    ! Keys added by Don
    Scalculator       :10000161
    6. Run
    Code:
    xmodmap ~/.Xmodmap
    to load the mapping.

    Now key presses will return with a name associated with the key. This will allow KDE
    to use the name of the key to start the program that you want.
    Code:
    KeyPress event, serial 28, synthetic NO, window 0x2c00001,
      root 0xa2, subw 0x0, time 1753495014, (1096,695), root:(1100,718),
      state 0x10, keycode 161 (keysym 0x10000161, Scalculator), same_screen YES,
      XLookupString gives 0 bytes:
      XmbLookupString gives 0 bytes:
      XFilterEvent returns: False
    
    KeyRelease event, serial 28, synthetic NO, window 0x2c00001,
      root 0xa2, subw 0x0, time 1753495014, (1096,695), root:(1100,718),
      state 0x10, keycode 161 (keysym 0x10000161, Scalculator), same_screen YES,
      XLookupString gives 0 bytes:
    7.Setup the .Xmodmap script to execute each time you login:
    Make a file ~/.kde/Autostart/Xsession and put the following lines in it:
    Code:
    #!/bin/sh
    if [ -f $HOME/.Xmodmap ]; then
      /usr/bin/xmodmap $HOME/.Xmodmap
    fi
    8.Change the ~/.kde/Autostart/Xsession file to that it is executable:
    Code:
    chmod uga+x ~/.kde/Autostart/Xsession
    9. Map keysym to application in KDE:
    System Settings > Regional & Accessibility > Keyboard Shortcuts > Command Shortcuts tab.
    Pick the program you want and assign the key by pressing it.

    Note that it is likely at some point the /usr/share/X11/XKeysymDB file will be overwritten when installing updates so you should backup whatever special keys you have added to another location so they can be added back to the file after the update.

    To duplicate for other users copy the ~/.Xmodmap and ~/.kde/Autostart/Xsession files to same
    locations in each user home directory and change the ownership so each person can run the script.




Working...
X