You are not logged in.

#1 2021-11-24 20:49:10

light9876
Member
Registered: 2020-01-05
Posts: 131

[SOLVED] Keyboard shortcuts not working for different layouts

I have two keyboards, one is Dell SK-8120 and the other Logitech K120.

I use two keyboards (Arabic and English), and I use the following commands to change layout:

setxkbmap gb
setxkbmap ara qwerty_digits

Now the case is that when I use the Logitech keyboard, and whenever the Arabic layout is activated, shortcuts such as Ctrl+C, Ctrl+A... do not work. I need to switch layout to english, press the shortcut, then switch back.

But this is not the case with the Dell keyboard. I can use these shortcuts inside the Arabic layout.

What is going on?

Last edited by light9876 (2021-11-28 22:13:06)

Offline

#2 2021-11-25 07:46:01

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: [SOLVED] Keyboard shortcuts not working for different layouts

Are the keyboards connected at the same time? Do they start w/ different default locales?
You maybe want to configure multiple layouts instead of juggling them w/ setxkbmap, see eg. https://wiki.archlinux.org/title/Xorg/K … tion_files
Your approach is slow and re-configures the keyboard and the behavior might depend on the layout that was used when the application was started.
The multilayout config might not immediately solve your problem, but make it much easier to switch forth and back.

After all, you're typing ctrl+ا - not ctrl+a. You could add a bunch of global shortcuts that map ctrl+ا, ctrl+خ etc. to "xdotool key ctrl+a", "xdotool key ctrl+c" etc.

Offline

#3 2021-11-27 21:26:24

light9876
Member
Registered: 2020-01-05
Posts: 131

Re: [SOLVED] Keyboard shortcuts not working for different layouts

They aren't connected at the same time.

Even after I tried this on a laptop, the keyboard of the laptop has the same problem. Only when I connect the Dell keyboard the shortcuts work.

The following rule does not work:

awful.key( {control},"Arabic_hamzaonwaw",function () awful.spawn("xdotool key Control_L+c") end, {description="copy", group="awesome"}),

"the behavior might depend on the layout that was used when the application was started" these commands (setxkbmap) change layout globally.

Offline

#4 2021-11-27 21:55:51

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: [SOLVED] Keyboard shortcuts not working for different layouts

these commands (setxkbmap) change layout globally

Yes, but a running processs might not (most won't) pick that up and shortcuts are bound by the code, not the symbol - https://tronche.com/gui/x/xlib/input/XGrabKey.html
(The complicated way of saying that if the procss starts on the english map, the symbol can be mapped to a keycode and that checked in event handling)

Even after I tried this on a laptop, the keyboard of the laptop has the same problem. Only when I connect the Dell keyboard the shortcuts work.

What's the output of "setxkbmap -print -query" with either keyboard *before* you do any "setxkbmap …" yourself?

Offline

#5 2021-11-27 23:30:36

light9876
Member
Registered: 2020-01-05
Posts: 131

Re: [SOLVED] Keyboard shortcuts not working for different layouts

The outputs are the same on all keyboards (and they remain the same even after running setxkbmap):

xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+gb+inet(evdev)"	};
	xkb_geometry  { include "pc(pc105)"	};
};
rules:      evdev
model:      pc105
layout:     gb
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+ara(qwerty_digits)+inet(evdev)"	};
	xkb_geometry  { include "pc(pc105)"	};
};
rules:      evdev
model:      pc105
layout:     ara
variant:    qwerty_digits

Last edited by light9876 (2021-11-27 23:31:26)

Offline

#6 2021-11-28 07:49:03

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: [SOLVED] Keyboard shortcuts not working for different layouts

Differences in the xorg log when you change the layouts (eg. one of the keyboards re-registers as new device and the other doesn't)?
Did you btw. try to configure a proper multilayout to switch between layouts? (see link in #2)

Offline

#7 2021-11-28 22:12:17

light9876
Member
Registered: 2020-01-05
Posts: 131

Re: [SOLVED] Keyboard shortcuts not working for different layouts

Excellent!

My problem was solved by simply running this command:

 localectl --no-convert set-x11-keymap gb,ara pc105 ,qwerty_digits grp: caps_toggle 

Thank you so much! I have been perplexed by this issue since I started using Arch! Now the two keyboards work as expected, all shortcuts work on the Arabic as well as on the English..

* * *

Now I have one last problem:

How do I know the status of the language? I am currently on awesome, and previously I used to map the caps lock key to do two things: 1. switch the language (setxkbmap gb) and 2. update a textbox in the awesome panel.

By changing the text of the textbox between AR/EN I know which keyboard I am currently using. The problem now is that the caps lock key is no longer being captured by awesome after I ran the command above, so I can't update any flags using the caps lock key..

I hope this is sufficient to describe the problem..

Last edited by light9876 (2021-11-28 22:14:15)

Offline

#8 2021-11-28 22:57:00

seth
Member
Registered: 2012-09-03
Posts: 51,056

Offline

Board footer

Powered by FluxBB