44

I found this im-launch startup entry after installing Ubuntu 19.10 which executes sh -c 'if ! [ -e "/usr/bin/ibus-daemon" ] && [ "x$XDG_SESSION_TYPE" = "xwayland" ] ; then exec env IM_CONFIG_CHECK_ENV=1 im-launch true; fi'

I want to know the purpose of this entry and what would happend if i disabled it ?

Afsal
  • 862
  • 3
  • 8
  • 20

4 Answers4

39

-e check the file /usr/bin/ibus-daemon exists or not? exist means true does not exist means false.

! wants to confirm above value is false if above value is true, it will not execute anything.

[ "x$XDG_SESSION_TYPE" = "xwayland" ] this can have either one of below values based on how you choose to login at the login screen. which session you will choose x11 or wayland.

"xx11" = "xwayland" "xwayland" = "xwayland"

example output of $XDG_SESSION_TYPE

administrator@pratap:~$ echo $XDG_SESSION_TYPE
x11

another example:

administrator@pratap:~$ echo $XDG_SESSION_TYPE
wayland
administrator@pratap:~$ 

if the first expression is false and x$XDG_SESSION_TYPE = xwayland then exec the command env IM_CONFIG_CHECK_ENV=1 im-launch true

if the first expression is true or x$XDG_SESSION_TYPE is not equal to xwayland then don't do anything.

see man test

! EXPRESSION
              EXPRESSION is false

and

   -e FILE
          FILE exists

you can read more about what this command does then exec env IM_CONFIG_CHECK_ENV=1 im-launch true;

see man env & man im-launch


By default in Ubuntu 19.10 /usr/bin/ibus-daemon exists. so the command will not be executed.

env IM_CONFIG_CHECK_ENV=1 im-launch true

when there is the file /usr/bin/ibus-daemon and my session is x11

here is something about IM

enter image description here

when there is no file /usr/bin/ibus-daemon and my session is wayland

here is the thing which is different from above, which means the env is applied and then a chain reaction followed.

enter image description here

so, if you disable or enable this from startup list nothing happens unless no existence of this file /usr/bin/ibus-daemon and your session is wayland conditions are met.

marc-andre benoit
  • 597
  • 1
  • 5
  • 20
PRATAP
  • 21,989
  • 8
  • 59
  • 121
  • 10
    Thank you . I appreciate your detailed answer for my doubt . People like you makes askubuntu.com awesome . – Afsal Nov 30 '19 at 09:21
  • 17
    Well, I can underdstand the syntax of the command - but in simple words: what does it do in the end? What *is* `im-launch`? – foobar Apr 24 '20 at 06:56
  • 4
    I know how to use manpages... But `man im-launch` does not enlighten me. It seems very low level. Why does Ubuntu put this into my user-space start programs? – foobar Apr 24 '20 at 06:59
  • 2
    its kind of thing related to multi languages, keyboard layouts.. specially some kind of chinees, japanees.. etc. – PRATAP Apr 24 '20 at 07:01
  • What I'm most confused about is the `true`. It appears to execute the program passed to it, so in this case it just executes `true`, which doesn't actually do anything. I'm trying to figure out why fcitx doesn't get started, because this startup script doesn't seem to do anything at all. It seems like it should instead run something like `im-launch $GTK_IM_MODULE`, in order to actually start the correct IM method. – Sam Bull Nov 17 '20 at 22:10
  • 1
    I agree with foobar. I left being puzzled, I had to spend 25 minutes of reading the comment again and again till I get the aha! moment. It is a good, detailed answer, but not a beginner-wise. Thanks anyway for the effort. – Yannis Dran Jan 31 '21 at 22:57
5

I was doing some research on how to configure Ubuntu to make it more performant and ended up here, which is interesting.

My im-launch startup entry:

sh -c 'if [ "x$XDG_SESSION_TYPE" = "xwayland" ] ; then exec env IM_CONFIG_CHECK_ENV=1 im-launch true; fi'

As answer was detailed by @UnKNOWn but @foobar's comment was my situation, so I took a deep dive.

Breaking The Command Down:

sh is a command language interpreter that executes commands read from a command line string, the standard input, or a specified file.

exec command in Linux is used to execute a command from the bash itself.

if CONDITION true THEN execute COMMAND

im-launch command is used to start a input method framework server daemon such a ibus-daemon, set up the appropriate environment variables for the client programs,and execute SESSION-PROGRAM such as x-session-manager.

ibus-daemon is a daemon program for ibus and it is also a start up program for users to activate ibus daemon, engines and panel.

daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user.

ibus is an intelligent input bus.

bus is simply a set of wires connecting multiple modules (processor, memory, IO devices).

The exec

Then my question was why do exec env when we are already execution the command from sh.

The exec command replaces the current shell process with the specified command. Normally, when you run a command a new process is spawned (forked), the exec command does not spawn a new process. Instead, the current process is overlaid with the new command. In other words the exec command is executed in place of the current shell without creating a new process.

Use of env - If you want to modify the environment for a program before executing the main program, you'd often write an script and at the end of it start the main program. But there is no need for the script to stay in memory at that time. So, exec is used in these cases so that, the main program can replace the mother script.

Anit Shrestha
  • 211
  • 3
  • 7
1

I have only one thing to add that was hinted by @UnKNOWn and his comment.

IM-Launch could mean Input Method. Such as the one referred to on wikipedia

This also supports Anit's answer by his mentioning ibus future readers can find on wiki here

In plain simple terms it would appear to be a way to check which keyboard layout/language is to be used.. but i wouldn't quote me ...From a google search microsoft has much to say on the subject.

Just thought the 'IM' bit was semi important and above answers weren't clear for me..

0xF2
  • 3,144
  • 4
  • 30
  • 55
Swim Fan
  • 11
  • 1
0

I added the following comment to my im-launch startup item: "Check for display server type, x11 or wayland"