im-launch in Ubuntu startup

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


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.

  • What are possible use of exec command?
  • https://stackoverflow.com/questions/18351198/what-are-the-uses-of-the-exec-command-in-shell-scripts
  • https://unix.stackexchange.com/questions/265405/meaning-of-exec-env-command