Answer the question
In order to leave comments, you need to log in
How to set custom hotkeys for each keyboard layout in Ubuntu?
In the keyboard layout settings in Windows, you can easily set a separate hot key for each keyboard layout. I use Ctr+Shift+1, Ctr+Shift+2 and Ctr+Shift+3. Very used to it.
At work, I have to use Ubuntu, out of habit, every time I need to switch the layout, I reach for this combination. In the Ubuntu settings, I did not find the ability to set my own hot keys for each language. Please tell me how to get out of this situation.
Answer the question
In order to leave comments, you need to log in
In general, I made a rather crutch, but quite a working solution. I wrote a script that emulates pressing the layout switching keys the required number of times. For the script to work, you need to install "xkb-switch" (to determine the current keyboard layout) and "xdotool" (to emulate keystrokes). The launch of the script is hung up on pressing the keys you need.
Script code:
#!/bin/bash
source_lang=`xkb-switch`
dest_lang=$1
# Если уже на нужной раскладке
if
then
exit 0
fi
# Необходимая задержка (без неё не сработает)
sleep 0.3
# Если 1 раз нужно нажать на переключение раскладки
if
then
xdotool key super+space
exit 0
fi
# Если 2 раза нужно нажать на переключение раскладки
if
then
xdotool key super+space super+space
exit 0
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question