alols / xcape

Linux utility to configure modifier keys to act as other keys when pressed and released on their own.
GNU General Public License v3.0
2.1k stars 117 forks source link

reverse operation #65

Closed wbolster closed 8 years ago

wbolster commented 8 years ago

is it possible to generate a fake modifier key when a normal key is pressed in combination with another normal key?

on osx, the karabiner tool allows for some magic behaviour of the tab key when it is pressed with the h and l keys: it allows for vim-like window navigation in "alt-tab style" using the tab key as a modifier. when pressed alone, tab just generates a tab.

is this possible to achieve under linux/xorg?

wbolster commented 8 years ago

i almost got it to work:

# Make tab a modifier key, acting like Alt_L. Then assign a unused keycode for
# Tab so that xcape can make it a Tab again if pressed by itself.
xmodmap -e 'keycode 23 = Alt_L' -e 'keycode 255 = Tab'
xcape -e 'Alt_L=Tab'

this makes tab-x act like alt-x, while still allowing tab by itself. alt-tab also works.

however, shift-tab now fails to work, and this is annoying since it's used to cycle backwards in many guis.

the xev tool gives this output when i type shift-tab:

FocusIn event, serial 42, synthetic NO, window 0xe00001,
    mode NotifyWhileGrabbed, detail NotifyNonlinear

KeymapNotify event, serial 42, synthetic NO, window 0x0,
    keys:  125 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

PropertyNotify event, serial 42, synthetic NO, window 0xe00001,
    atom 0x126 (_NET_WM_STATE), time 20299751, state PropertyNewValue

FocusIn event, serial 42, synthetic NO, window 0xe00001,
    mode NotifyUngrab, detail NotifyNonlinear

KeymapNotify event, serial 42, synthetic NO, window 0x0,
    keys:  3   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeyPress event, serial 42, synthetic NO, window 0xe00001,
    root 0x7d, subw 0x0, time 20302826, (1116,820), root:(1153,921),
    state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 42, synthetic NO, window 0xe00001,
    root 0x7d, subw 0x0, time 20303034, (1116,820), root:(1153,921),
    state 0x1, keycode 23 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 42, synthetic NO, window 0xe00001,
    root 0x7d, subw 0x0, time 20303114, (1116,820), root:(1153,921),
    state 0x9, keycode 23 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

MappingNotify event, serial 42, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 42, synthetic NO, window 0xe00001,
    root 0x7d, subw 0x0, time 20303115, (1116,820), root:(1153,921),
    state 0x1, keycode 255 (keysym 0xff09, Tab), same_screen YES,
    XLookupString gives 1 bytes: (09) " "
    XmbLookupString gives 1 bytes: (09) "   "
    XFilterEvent returns: False

KeyRelease event, serial 42, synthetic NO, window 0xe00001,
    root 0x7d, subw 0x0, time 20303116, (1116,820), root:(1153,921),
    state 0x1, keycode 255 (keysym 0xff09, Tab), same_screen YES,
    XLookupString gives 1 bytes: (09) " "
    XFilterEvent returns: False

MappingNotify event, serial 43, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyRelease event, serial 43, synthetic NO, window 0xe00001,
    root 0x7d, subw 0x0, time 20303258, (1116,820), root:(1153,921),
    state 0x1, keycode 50 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XKeysymToKeycode returns keycode: 66
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 44, synthetic NO, window 0xe00001,
    mode NotifyNormal, detail NotifyNonlinear
alols commented 8 years ago

duplicate of #16