2

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?

PRATAP
  • 22,460
Eric
  • 21

2 Answers2

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.

Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94
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.

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

    screenshot

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

  3. read manpage man xcape

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

Script (source):

#!/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

Pablo Bianchi
  • 15,657
PRATAP
  • 22,460