1

I want to use an external numpad as a 'macro keyboard' with each key being able to perform a specified action. I have already created a custom xkb_keymap to map keys to XF86 symbols.

$ cat ~/.xinitrc
...
# Active macro keyboard
macrokb=$( xinput list | sed -n 's|.*MOSART.*2\.4G.*id=\([0-9]*\).*keyboard.*|\1|p' | head -n1 )
if [ "$macrokb" ]; then
  cat ~/.xkb/macros.xkb | xkbcomp -i $macrokb - $DISPLAY
fi

$ cat ~/.xkb/macros.xkb 
xkb_keymap "macros" {

xkb_keycodes {
    // 0 - Chrome
    <WEB> = 90;
    // / - Windows
    <WIN> = 106;
    // * - Win attach
    <ATCH> = 63;
    // BS - Win detach
    <DTCH> = 22;
    // enter - Terminal
    <TERM> = 104;
    // numlock - Settings
    <SETT> = 77;
};

xkb_types {
    include "basic"                                                                                                 
    include "numpad"                                                                                                
};                                                                                                                  

xkb_compat { include "basic" };                                                                                     

xkb_symbols {                                                                                                       
    key.type = "ONE_LEVEL";                                                                                         
    key <WEB> { [ XF86WWW ] };                                                                                      
    key <WIN> { [ XF86Launch0 ] };                                                                                  
    key <ATCH> { [ XF86Launch1 ] };                                                                                 
    key <DTCH> { [ XF86Launch2 ] };                                                                                 
    key <TERM> { [ XF86Terminal ] };                                                                                
    key <SETT> { [ XF86Tools ] };                                                                                   
};                                                                                                                  

};

The custom keyboard map is successfully loaded and is detected by xev. Example: 

KeyPress event, serial 41, synthetic NO, window 0x5800001,
    root 0x4f7, subw 0x0, time 5314499, (1656,414), root:(1656,443),
    state 0x10, keycode 106 (keysym 0x1008ff40, XF86Launch0), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

Now here comes the problematic part: when I create a custom keyboard shortcut in KDE, it successfully recognizes the XF86 keysym e.g. WWW or Terminal but the script I provided is not executed (so the shortcut is not detected by KDE).

This is not the case however, for some other keys (in-built into my main keyboard) e.g. XF86AudioPlay.

How can I fix this problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.