1

I have two commands those are binded with CapsLock key and Shift+CapsLock as mentioned in this Q&A Modeless/stateless layout language switching with Caps Lock, again (18.04 LTS Bionic Beaver)

My requirement is to toggle the languages with Super+Space without graphical representation on screen.

enter image description here

I have disabled the default shortcuts for switch to next input source and previous input source.

enter image description here

now I can bind any command to Super+Space like below

enter image description here

Thoughts:

It is possible to give these two commands as two shortcuts for example:

Super+Space for English
Shift+Super+Space for Ukranian

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()"

When the value is 1 in "inputSource[ ]" the language changes to Ukranian and if it is 0 language changes to English

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()"

Question:

I am looking for a command that can read the present value and change to other value among 0 and 1 in the below command so that I can toggle the languages without the need of Shift+Super+Space

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()"
  • See this git. – danzel Apr 17 '19 at 13:46
  • @danzel can you post the script as answer.. credit goes to you.. – YuganTej Apr 17 '19 at 14:25
  • that's not my script. I googled "imports.ui.status.keyboard.getInputSourceManager" looking for some documentation, and the git repo was the first result. I actually don't use gnome so I cannot test it. Feel free to post it yourself if it works. – danzel Apr 17 '19 at 14:55
0

With the help of @danzel, the link provided by him..https://github.com/Nekotekina/kbhook/blob/master/layout_rotate.sh

I have saved the below script as ~/SL.sh and created a shortcut with Super+Space as
/bin/bash /home/pratap/SL.sh

enter image description here

#!/bin/bash

CURRENT=`gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().currentSource.index"`

if [ "$CURRENT" == "(true, '1')" ]; then
  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()"
else
  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()"
fi

now Super+Space is toggling the Languages without graphical representation which I was looking for..

enter image description here

thanks to @danzel once again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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