9

Can I set up keyboard shortcuts for each input language? For example I want to set "Ctrl + 8" for English, "Ctrl + 9" for Ukrainian and "Ctrl + 0" for Russian languages. I don't want to switch and search language I need. It takes time. I want directly to turn language I want. I had this ability in Windows. Maybe I need to install some plugin?

3 Answers 3

9

Go to System Settings - Keyboard - Shortcuts. Click on "Add" button.

(See here for how to create a custom shortcut: http://web.archive.org/web/20150705203244/http://bigknol.com/create-custom-keyboard-shortcuts-in-ubuntu-for-launching-chrome-firefox/)

enter image description here

For the name write,for example name of the input language - "English".

For the command write

gsettings set org.gnome.desktop.input-sources current 0

Here 0 indicates the number of the input language. (0 for the first one, 1 for the second one, etc.)

Then press on create a shortcut button and press the key combination you want.

Change the number according to the order of input languages. For example write

gsettings set org.gnome.desktop.input-sources current 1

for creating a shortcut for the second language.

6

As far as current is deprecated for org.gnome.desktop.input-sources in GNOME 3.2 so for Ubuntu 18.04, you can use one of the following commands:

  1. For the first language:

    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()"
    
  2. For the second language:

    gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[1].activate()"
    
2
  • So this is applicable only for GNOME DE? What if I use XFCE?
    – Suncatcher
    Mar 9, 2018 at 12:27
  • This really should be up-voted since the accepted answer no longer works :)
    – qrikko
    Mar 22, 2021 at 15:03
2

Since Ubuntu 22.04 GNOME no longer allows the use of input-sources or accepts Eval() natively so you have to use the following workaround.

  1. Install GNOME extension Eval-GJS - This extension provides unrestricted Eval() dbus method for running arbitrary code in the compositor.
https://github.com/ramottamado/eval-gjs.git
cd eval-gjs
make install
  1. Install gnome-shell-extension-manager
sudo apt install gnome-shell-extension-manager
  1. Logout and re-login

  2. Launch gnome-shell-extension-manager and enable Eval-GJS

  3. Go to Settings -> Keyboard -> Keyboard Shortcuts and add a custom shortcut with the following command:

gdbus call --session --dest org.gnome.Shell --object-path /dev/ramottamado/EvalGjs --method dev.ramottamado.EvalGjs.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()"

Replace the index in inputSources[0] with the actual index of the input method you wish to change to. First layout will be inputSources[0], second layout will be inputSources[1] and so on.

2
  • And since Ubuntu 23.04 Eval-GJS "is incompatible with the current GNOME version" :(
    – fetsh
    Mar 21 at 12:50
  • Ok, Eval-GJS have to up the version in manifest, to make it work with current GNOME, but for now this should work: github.com/fetsh-edu/eval-gjs/commit/…
    – fetsh
    Mar 21 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.