<< Back Home EN en   Donate Donate

Alt+Shift for Input switch under newer Ubuntu

Use Alt+Shift ot Ctrl+Shift

For some reason newer Ubuntu (e.g. 20) with Gnome prevents from setting Ctrl-Shift or Alf-Shift sequence for keybpoard layout switching. But there is a method to make it working in the was some of us are used to.

gsettings list-recursively | grep  org.gnome.desktop.wm.keybindings | grep input
org.gnome.desktop.wm.keybindings switch-input-source ['<Super>space', 'XF86Keyboard']
org.gnome.desktop.wm.keybindings switch-input-source-backward ['<Shift><Super>space', '<Shift>XF86Keyboard']

And now some magic

gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Alt>Shift_L']"
gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Control>Shift_L']"

Static layout switching order

A bit more complicated. Newer Gnome uses adaptive layout order, not cycling in the same order. If you want to have static order, e.g. always EN - RU - UK - EN ..., then you need external script :( We shall bind it to custom sequence. If you need legacy shortcut (Alt+Shift or Ctrl+Shift), follow instruction below



if [ "x$1" = "x" ] ; then
  totalLang=$(gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager()._mruSources.length" | grep -oP "(?<=').*?(?=')")
  currentLang=$(gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().currentSource.index" | grep -oP "(?<=').*?(?=')")
  declare -i math=$currentLang+1
  declare -i totalLang=$math+1

if [ "$math" -lt "$totalLang" ]; then
  gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources["$currentLang+1"].activate()"
  gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()"

Make it executable

sudo chmod 755 /usr/local/bin/

Now go to Settings - Keyboard shortcuts - Typing and reset Switch to next input source to default. Then add new custom shortcut at the bottom, lets name it Switch to next input source static with some shortcut, e.g. Alt-Z and path to executable /usr/local/bin/

sudo apt install dconf-cli
dconf dump /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/
name='Switch to next input source static'

And now change shortcut

dconf write "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/binding" \

Shortcuts to individual layouts

You need the same< with parameter. 0 corresponds to the 1st language in layout list. So, make custom shortcuts like Win+F1 with command '/usr/local/bin/ 0', Win+F2 with '/usr/local/bin/ 1', etc.


FB or mail (remove X)   Share
Автор: Alter (Александр А. Телятников) Сервер: Apache+PHP под FBSD © 2002-2024