7/23/2021 10:15pm

i3wm Ubuntu Chewing/English input

I recently gained interest in ricing my ubuntu box. So I dived right into it! I'm still learning how to customize the window manager to my liking at the moment. I type with input methods English-US and Chinese, the ibus Chewing to be exact. I noticed I couldn't switch the input methods like I did before with gnome de. Since i3 is just a window manager, I figured I need to bind some keys that will execute that for me.


I decided to utilize mode with i3 bindings and use ibus command line to switch my input methods.


My first step was to confirm the engine names with ibus

ibus engine

The line above returned xkb:us::eng


I then listed all engine names and located the one that I wanted

language: Chinese

   chewing - Chewing


After grabbing the information needed, I moved on to the next step


I tested the command lines to ensure my language input methods switch as desired

ibus engine "xkb:us::eng"

ibus engine "Chewing"


I confirmed that the commands worked as intended. I was able to switch to Chewing and type as usual. Used the shift key to change between chewing and English within the Chewing input method then used the command lines to go back to xkb:us::eng.


The rest was decide how I want to configure the key bindings with the i3 config file

I used my preferred text editor vim and went into the config file

vim .config/i3/config


I decided to use a mode for my language input switches. Below is my configuration


# i3 language keyboard input (c) chewing, (e) English-US
mode "language_input_mode" {
        # These bindings trigger as soon as you enter the language input mode

        # Pressing c will change it to Chinese-Chewing
        # Pressing e will change it to English-US
        bindsym c exec --no-startup-id ibus engine "chewing"
        bindsym e exec --no-startup-id ibus engine "xkb:us::eng"


        # back to normal: Enter or Escape or Control+Shift+l
        bindsym Return mode "default"
        bindsym Escape mode "default"
        bindsym Control+Shift+l mode "default"
}
bindsym Control+Shift+l mode "language_input_mode"


I :w the script and ran $mod+Shift+r to restart i3. I tested my mode and key bindings and VOILA!


I hope my quick blog helps with those who use ibus for input methods and i3 for window manager.

HAPPY RICING!


Image by LIN LONG from Pixabay 

Write your code here.

Cloud Engineering Analyst

Server IP: 10.70.0.122

Request IP: 80.85.245.145