You are not logged in.

#1 2022-05-20 20:49:07

ilrinato
Member
Registered: 2021-07-17
Posts: 1

Switching keyboard layouts

**END GOAL**

I use bspwm as my window manager and sxhkd as a hotkey daemon. I want to map a certain key combination in my sxhkdrc so that it shuffles through different keyboard layouts. For example:

# Shuffle through keyboard layouts
super + e
    *action to be executed*

The three layouts I want to use (be able to shuffle through) are:

- us = US English
- sr-cy = Serbian in Cyrillic script
- sr-latin = Serbian in Latin script


**LOCALES**

First, I do not know whether I am required to add Serbian locales as I only (from time to time) want to activate the Serbian keyboard layouts. My thinking is that keymaps are enough. Just in case, I generated Serbian locales; so now when I run "localectl list-local", the output is:

en_US.UTF-8
sr_RS.UTF-8
sr_RS.UTF-8@latin

These respectively correspond to:

- English locale for the U.S. – UTF-8 encoding
- Serbian locale for Serbia – Cyrillic script – UTF-8 encoding
- Serbian locale for Serbia – Latin script – UTF-8 encoding



**KEYMAPS**

I know that I can edit "/etc/vconsole.conf" and set "KEYMAP=sr_cy" instead of "us" or use "localectl set-keymap sr_cy".

Here are my concerns with that:

1. It is not an elegant solution.
2. I cannot shuffle through different layouts. I have to run the command and specify the desired layout each time.
2. Would such change persists globally even after I log out or reboot the system? If the answer is yes, I will potentially be in trouble. I use LVM on LUKS encryption and for me to decrypt my disk I need `us` layout. Hence, if I forget to switch from Cyrillic script before rebooting, it's bye bye forever.



**QUESTION**

Is there any way for me to add multiple keymaps in "/etc/vconsole.conf" and have the "us" be the default one? If so, what do I need to do to switch between them. Is it a simple command or do I need a small script? If that is not an option, what is the best way to get to my end goal.

I have tried finding the answer to having multiple keymaps but I was not able to find anything applicable to my problem. I would appreciate a solution or even advice and suggestions especially if it advances my knowledge. Thank you in advance!

Last edited by ilrinato (2022-05-20 20:52:43)

Offline

#2 2022-05-20 21:17:30

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

Re: Switching keyboard layouts

sxhkd has nothing to do w/ vconsole.conf - the latter is for the console, but you're concerned w/ an X11 environment
The keyboard layout is also not related to the locale (at all)

https://wiki.archlinux.org/title/Xorg/K … rd_layouts
You can also "xdotool key ISO_Next_Group" to cycle to the next layout.

nb. that layout switches will not easily align w/ (all) shortcut daemons (no idea whether sxhkd in particular picks up the layout change and adjusts its grabs) ie. the shortcut daemon may trigger on the layout that was in place when it started rather than the current one.

Offline

Board footer

Powered by FluxBB