You are not logged in.

#1 2012-07-25 12:13:33

w0ng
Member
From: Australia
Registered: 2009-06-04
Posts: 88
Website

dwm: Remapping Shift+Insert to Mod4+p

I'm looking for a way to globally map Shift+Insert to Super_L+p for easier finger access to primary buffer pasting across terminal and gtk apps.

I'm trying to do this with xdotool.

Relevant lines from my config.h:

...
#define MODKEY Mod4Mask
...
static const char *pastecmd[]       = { "xdotool", "key", "--clearmodifiers", "Shift+Insert", NULL };
...
  { MODKEY,                 XK_p,             spawn,          {.v = pastecmd } },
...

After compiling and restarting, Mod4+p doesn't work as I'd expect (i.e. nothing happens when super+p is pressed).
Running "xdotool key --clearmodifiers Shift+Insert" from shell and dmenu works (primary buffer is pasted).
Running "sleep 5 && xdotool key --clearmodifiers Shift+Insert" from shell and dmenu, then focussing a text box in a gtk app such as Firefox within 5 seconds also works.

Looking for info on why this isn't working?
Perhaps theres another tool or way of mapping key combos that would do this job. Suggestions?

Offline

#2 2012-07-25 12:16:20

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: dwm: Remapping Shift+Insert to Mod4+p

try xbindkeys.

Last edited by x33a (2012-07-25 12:16:33)

Offline

#3 2012-07-25 13:03:54

w0ng
Member
From: Australia
Registered: 2009-06-04
Posts: 88
Website

Re: dwm: Remapping Shift+Insert to Mod4+p

Doesn't work with xbindkeys.

~/.xbindkeysrc

"xdotool key --delay 0 --clearmodifiers Shift+Insert"
    m:0x40 + c:33
    Mod4 + p

xev output after the mapping:

KeyPress event, serial 29, synthetic NO, window 0xe00001,
    root 0x157, subw 0x0, time 11820231, (486,597), root:(488,613),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XKeysymToKeycode returns keycode: 108
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 32, synthetic NO, window 0xe00001,
    mode NotifyGrab, detail NotifyAncestor

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

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

FocusIn event, serial 33, synthetic NO, window 0xe00001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 33, synthetic NO, window 0x0,
    keys:  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           32  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeyRelease event, serial 34, synthetic NO, window 0xe00001,
    root 0x157, subw 0x0, time 11821150, (486,597), root:(488,613),
    state 0x40, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XKeysymToKeycode returns keycode: 108
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

xbindkeys -k after mapping:

Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"NoCommand"
    m:0x40 + c:133
    Mod4 + Super_L

(the same xev and xbindkeys -k output occurs when doing the mapping in dwm's config.h)

Offline

#4 2012-07-25 13:14:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,555
Website

Re: dwm: Remapping Shift+Insert to Mod4+p

Going with the xdotool route, have you tried using the SHCMD macro and/or using:

static const char *pastecmd[]       = { "/bin/sh", "-c", "xdotool key --clearmodifiers Shift+Insert", NULL };

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2012-07-25 13:18:21

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: dwm: Remapping Shift+Insert to Mod4+p

Maybe it's a keyboard problem? What kind of keyboard are you using?

Offline

#6 2012-07-25 14:20:38

w0ng
Member
From: Australia
Registered: 2009-06-04
Posts: 88
Website

Re: dwm: Remapping Shift+Insert to Mod4+p

@Trilby
Yep. I tried with that line and SHCMD directly with this line before posting this question:

{ MODKEY,                 XK_p,             spawn,          SHCMD("xdotool key --clearmodifiers Shift+Insert") },

@x33a
Using Leopold FC700r plugged into PS/2. It's a month or two old and everything working fine that I'm aware of.
Maybe not related, but I'm also using these in my ~/.xinitrc before dwm is launched.

# remap caps lock to escape, remap right alt to window key
setxkbmap -option caps:escape
xmodmap -e "keycode 108 = Super_L"
xmodmap -e "remove mod1 = Super_L"

Offline

#7 2012-07-25 15:48:16

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: dwm: Remapping Shift+Insert to Mod4+p

Maybe the xmodmap lines are interfering somehow? Try commenting them out and see if it makes a difference.

Offline

#8 2012-07-26 07:34:11

w0ng
Member
From: Australia
Registered: 2009-06-04
Posts: 88
Website

Re: dwm: Remapping Shift+Insert to Mod4+p

Tried without the setxkbmap and xmodmapping in xinitrc and with and without --clearmodifiers.
Still couldn't get it to work.
I'll stop trying until I get another keyboard to see if it is a keyboard problem

Offline

Board footer

Powered by FluxBB