You are not logged in.

#1 2016-11-01 14:20:32

beardedlinuxgeek
Member
Registered: 2012-09-17
Posts: 32
Website

Very strange issue with remapped keys and Xfce

My laptop has the Home and End keys as Fn keys, which I think is annoying. So I remapped other keys I don't use frequently. Specifically, I remapped Insert to Home. I did this using Xmodmap and it works really well. Every time I press Insert, it has the effect of pressing Home. Except for this one specific case...

In Xfce, the keyboard shortcut to move a Window to the previous workspace is <Primary><Alt><Home>. If I try and do that with the Insert key that I've remapped to Home, it doesn't work. But if I use the original Home key (I never disabled the function keys), then it does work. To make matters stranger, I did a test by opening the Keyboard manager in Xfce and trying to set Primary+Alt+Home (using the fake home key) to something else and it said it was already being used for "move window to prev workspace." So clearly Xfce is recognizing my remapped Insert key as a Home key, but the shortcut doesn't work.

Here is the xev output when I press Insert (which is remapped to Home):

KeyRelease event, serial 37, synthetic NO, window 0x2a00001,
    root 0xf5, subw 0x2a00002, time 1881763, (56,31), root:(927,514),
    state 0x10, keycode 118 (keysym 0xff50, Home), same_screen YES,
    XKeysymToKeycode returns keycode: 110
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

And here is the output when I press the Fn Home key:

KeyPress event, serial 37, synthetic NO, window 0x2a00001,
    root 0xf5, subw 0x2a00002, time 1884316, (56,31), root:(927,514),
    state 0x10, keycode 110 (keysym 0xff50, Home), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

Any ideas?

Offline

#2 2016-11-01 15:40:20

beardedlinuxgeek
Member
Registered: 2012-09-17
Posts: 32
Website

Re: Very strange issue with remapped keys and Xfce

Still haven't figured out how the fix the issue, but I did come up with a workaround. I'd like for this to work the right way, but in the meantime (and for anyone who stumbles across this thread off Google), this is what I'm doing:

I created these two scripts, and then I disabled the workplace switcher that is build into Xfce and instead mapped Ctrl+Alt+Home/End to these scripts.

move-window-next-workspace.sh

#!/bin/bash
CURRENT=$(wmctrl -d | \grep \* | tr -s " " | cut -d' ' -f1)
NEXT=$((($CURRENT+1)%4))
WINID=$(xdotool getwindowfocus)
wmctrl -i -r $WINID -t $NEXT; wmctrl -s $NEXT; wmctrl -i -R $WINID

move-window-prev-workspace.sh

#!/bin/bash
CURRENT=$(wmctrl -d | \grep \* | tr -s " " | cut -d' ' -f1)
PREV=$((($CURRENT-1)%4))
if [ "$PREV" -lt "0" ]
  then
    PREV=3
fi
WINID=$(xdotool getwindowfocus)
wmctrl -i -r $WINID -t $PREV; wmctrl -s $PREV; wmctrl -i -R $WINID

And this works fine. Apparently something is going on with Xfce not respecting Xmodmap changes for built in functions like switching workspaces.

The scripts first get the current workspace you're in. Then it calculates the next (or previous) workspace. Then get the ID of the active window, move that window to the next/previous workspace, and then raise and give focus to that window. I had to use the window ID instead of :ACTIVE: in order to give the window focus when you switch to the next workspace.

Offline

#3 2016-11-01 22:00:46

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,566

Re: Very strange issue with remapped keys and Xfce

You're most likely calling xmodmap *after* xfce grabbed the keys for the shortcuts.
(Unfortunately I've no idea about xfce's startup procedure ie. which scripts would be executed before whatever is the shortcut server kicks in - if any)

Offline

#4 2016-11-03 10:25:28

beardedlinuxgeek
Member
Registered: 2012-09-17
Posts: 32
Website

Re: Very strange issue with remapped keys and Xfce

seth wrote:

You're most likely calling xmodmap *after* xfce grabbed the keys for the shortcuts.
(Unfortunately I've no idea about xfce's startup procedure ie. which scripts would be executed before whatever is the shortcut server kicks in - if any)

The default .xinitrc file (which I'm using) looks like

usermodmap=$HOME/.Xmodmap
xmodmap "$usermodmap"
exec startxfce4

So xmodmap is definitely being called before xfce. I don't use any login script, I sign into the virtual console and execute `startx` manually.

Offline

#5 2016-11-03 14:51:59

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,566

Re: Very strange issue with remapped keys and Xfce

Seems odd. What if you restart <whatever is the xfce shortcut daemon, maybe xfwm?> during the session?

Offline

Board footer

Powered by FluxBB