Grouped keyboard layouts or cycle the last two (Mint 19)

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
dim
Level 1
Level 1
Posts: 2
Joined: Fri Jan 18, 2019 9:09 am

Grouped keyboard layouts or cycle the last two (Mint 19)

Post by dim »

I have multiple keyboard layouts (ru,cz,en). Is there any possibility to group layouts and switch between groups? Let's say group 1 is ru only, group 2 is en+cz and switch between groups via alt+shift and switch within a group via ctrl+shift (en/cz). It also would be ok to cycle the last two layouts (like ubuntu layout-switch), but i didn't found that option in xkb. I've found several bash scripts but none of them worked in Mint 19 (cycling the last two layouts). Cycling all three layouts all the time is just pure pain...
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
dim
Level 1
Level 1
Posts: 2
Joined: Fri Jan 18, 2019 9:09 am

Re: Grouped keyboard layouts or cycle the last two (Mint 19)

Post by dim »

Well, ok, since it's linux, so... help yourself solution here with cycling 2 keyboard layouts is:

1. Install xkb-switch (https://github.com/ierton/xkb-switch)

Code: Select all

sudo apt install cmake libxkbfile-dev build-essential

git clone https://github.com/ierton/xkb-switch.git

cd xkb-switch

mkdir build && cd build

cmake ..

make

sudo make install

sudo ln -s /usr/local/lib/libxkbswitch.so.1 /usr/lib/libxkbswitch.so.1
2. Make bash script

Code: Select all

sudo vim /usr/local/bin/xkb-toggle-en-ru
Place this inside (modify for your needs):

Code: Select all

#!/bin/bash
LANG1="us"
LANG2="ru"
CURRENT_LANG=$(xkb-switch)
if [ "$CURRENT_LANG" = $LANG1 ]; then
    xkb-switch -s $LANG2
else
   xkb-switch -s $LANG1
fi
3. Make script executable

Code: Select all

sudo chmod +x /usr/local/bin/xkb-toggle-en-ru 
4. Test

Code: Select all

xkb-toggle-en-ru
It should toggle your layouts

5. Go to keyboard settings and change Alt+Shift toggling to anything else (e.g. Shift+CapsLock)

6. Make new shortcut in keyboard settings with command "xkb-toggle-en-ru" and assign Alt+Shift to it.

Done.
Locked

Return to “Cinnamon”