1

I am switching from windows to ubuntu and would like to achieve the same input method as in windows. I am now using English(US) and ibus-cangjie for input. I want to change the input layout by clicking the left shift. After google, I found that the additional layout setting in tweak can help.

additional layout setting

However, the problem is it completely overrides the left shift key. For example, in windows, I can enter capital letters and enter symbols from the number key by long holding shift in English mode. When I do that in Ubuntu, after I long press and hold the left shift key it immediately changes to another layout. Therefore, I cannot input capital letters and symbols with the left shift key.

Is that any way to achieve the correct behavior: when short click the shift button input layout changes and when long press and hold the shift key capitalize letters or enter symbol with number key?

2
  • how many layouts you have? – UnKNOWn Nov 1 '20 at 4:02
  • 2, English(US) and ibus Chinese. – Eric Nov 1 '20 at 4:06
0

Intelligent Pinyin and Bopomofo (the ibus-libpinyin package) use Shift as a built-in shortcut for switching between Chinese and English. So when you long press Shift you can type capital English letters without switching mode. Just tapping Shift changes the mode to/from Chinese.

So if you use Intelligent Pinyin or Bopomofo and disable the shortcut you set via Tweaks it should do what you want.

5
  • 1
    Thank you for reply but sorry I didn't specify my input layout. Pinyin is used in mainland China but I use ibus-cangjie in hong kong. After testing your solution there is no such built in function with my input method. – Eric Nov 1 '20 at 4:24
  • @Eric: ibus-libpinyin includes Bopomofo too, which is for Traditional Chinese if I understand it correctly. Works the same way. – Gunnar Hjalmarsson Nov 1 '20 at 4:30
  • Unfortunately, that's different from what I am using also. – Eric Nov 1 '20 at 4:53
  • @Eric: Then I'm out of ideas. Besides picking some other key, such as <Caps Lock>, for switching layouts. – Gunnar Hjalmarsson Nov 1 '20 at 5:09
  • @Erik: The ibus-chewing package comes with a similar built-in shortcut. – Gunnar Hjalmarsson Nov 1 '20 at 5:45
0

@GunnarHjalmarsson's answer seems to be perfect fit when you compare with windows equivalent. As you mentioned in your comments it does not fit.

You can have a workaround but bit time kill and not a good idea..

workaround

First remove the setting that you made from gnome-tweaks i.e. Left Shift as switching the layout.

  1. set a custom keyboard shortcut via command line by following this post. https://askubuntu.com/a/597414/739431

give any name.
give the command as bash /path/to/script
give the key as XF86Phone which we dont use in common or change any other key as you wish in same idea.

enter image description here

  1. Install the package xcpae with the command sudo apt install xcape

  2. read manpage man xcape

  3. run the command xcape -e 'Shift_L=XF86Phone'

script, source: https://askubuntu.com/a/1198150/739431

#!/bin/bash

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

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

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.