46

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 ?

4 Answers 4

40

-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.

6
  • 10
    Thank you . I appreciate your detailed answer for my doubt . People like you makes askubuntu.com awesome .
    – Afsal
    Nov 30, 2019 at 9: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, 2020 at 6: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, 2020 at 6:59
  • 2
    its kind of thing related to multi languages, keyboard layouts.. specially some kind of chinees, japanees.. etc.
    – PRATAP
    Apr 24, 2020 at 7:01
  • 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. Jan 31, 2021 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.

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..

2
  • 1
    This is a comment not an answer, you should have posted this as such.
    – David
    Feb 4, 2022 at 14:23
  • It looks like a valid answer to me.
    – karel
    Feb 4, 2022 at 17:35
0

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .