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

map modifier to mouse button click #132

Closed planet36 closed 3 years ago

planet36 commented 3 years ago

I want to map a momentary press of the Shift key to a mouse left click (or double click).

Is this possible with xcape?

In /usr/include/X11/keysymdef.h I found these definitions:

#define XK_Pointer_Button_Dflt           0xfee8
#define XK_Pointer_Button1               0xfee9
#define XK_Pointer_DblClick_Dflt         0xfeee
#define XK_Pointer_DblClick1             0xfeef

Trying to use any of those results in an error.

$ xcape -d -t 500 -e 'Shift_L=Pointer_Button_Dflt'

Assigned mapping from "Shift_L" ( keysym 0xffe1, key code 50) WARNING: No keycode found for keysym Pointer_Button_Dflt (0xfee8) in mapping Shift_L. Ignoring this mapping. Failed to parse_mapping

$ xcape -d -t 500 -e 'Shift_L=Pointer_Button1'

Assigned mapping from "Shift_L" ( keysym 0xffe1, key code 50) WARNING: No keycode found for keysym Pointer_Button1 (0xfee9) in mapping Shift_L. Ignoring this mapping. Failed to parse_mapping

$ xcape -d -t 500 -e 'Shift_L=Pointer_DblClick_Dflt'

Assigned mapping from "Shift_L" ( keysym 0xffe1, key code 50) WARNING: No keycode found for keysym Pointer_DblClick_Dflt (0xfeee) in mapping Shift_L. Ignoring this mapping. Failed to parse_mapping

$ xcape -d -t 500 -e 'Shift_L=Pointer_DblClick1'

Assigned mapping from "Shift_L" ( keysym 0xffe1, key code 50) WARNING: No keycode found for keysym Pointer_DblClick1 (0xfeef) in mapping Shift_L. Ignoring this mapping. Failed to parse_mapping

planet36 commented 3 years ago

I found a solution using xmodmap, xcape, sxhkd, and xte.

(in .xinitrc)

# Look for unused KeyCodes
#xmodmap -pk

# Map F13 to an unused KeyCode
xmodmap -e 'keycode 253 = F13'

xcape -e 'Shift_L=F13'

(in .config/sxhkd/sxhkdrc)

@F13
    xte 'mouseclick 1' 'mouseclick 1'