systemctl input method setting

0

I want to input Korean language on Ubuntu 18.04, electron application.

When the electron application is started on terminal by using yarn start, Korean language input works well via ibus.

But, when it is started by systemctl, Korean language input is not work.

Are there environment setting for input method of systemctl service?

The systemctl service is following.

[Unit]
After=multi-user.target

[Service]
User=my
Type=idle
WorkingDirectory=/home/my/electonapp
ExecStart=/usr/bin/yarn start
Restart=always
Environment=DISPLAY=:0.0
RestartSec=30

[Install]
WantedBy=multi-user.target

hando han

Posted 2019-02-18T06:56:14.733

Reputation: 3

Answers

0

Yes, you are missing a whole lot of environment variables. This is the expected result, as the "global" (system-wide) systemd .service units are meant to start background services and explicitly not meant for X11 applications (or anything that requires being "inside" a particular user session).

  • For example, XDG_RUNTIME_DIR is now required by many graphical applications as it contains various session daemons' IPC sockets.

  • IBus likely requires D-Bus, which may be covered by XDG_RUNTIME_DIR in "user session" environments, but may also need DBUS_SESSION_BUS_ADDRESS in "traditional" sessions.

  • And the program itself may need to be told to use IBus through GTK_IM_MODULE or XMODIFIERS.

For starting a program on user login, first consider whether simple ~/.config/autostart/ would do the job. If you specifically need systemd functionality, check if systemd --user is used by your distribution (it exists in pretty much all of them except CentOS).

If you have systemd --user running, you can use it to start and manage your application:

  1. If your distribution has a dbus-user-session package, install it. Upon reboot, your $DBUS_SESSION_BUS_ADDRESS should change to "unix:path=/run/user/…/bus".

  2. Convert your .service into a "user" unit at ~/.config/systemd/user/myapp.service:

    [Service]
    Type=simple
    WorkingDirectory=/home/my/electonapp
    ExecStart=/usr/bin/yarn start
    Restart=always
    RestartSec=30
    

    There's no User=, as all your units run under your own account.

    Note that this example doesn't have an [Install] section, as even systemd --user doesn't have an apropriate .target for this yet. (It has default.target, but this actually runs during login, before X11 is available.) Therefore it'll need to be auto-started in a different way.

  3. Change your X11 startup scripts to run the following commands:

    systemctl --user import-environment
    systemctl --user start myapp.service
    

    Note that many distros already call import-environment automatically, so usually all you need is the start command.

    For example, you can create a ~/.config/autostart/systemd-myapp.desktop with:

    [Desktop Entry]
    Type=Application
    Exec=systemctl --user start myapp
    

user1686

Posted 2019-02-18T06:56:14.733

Reputation: 283 655

Oh, thanks a lot. This is exactly what I want to know. I already knew use X11-application is not good on systemctl, but didn't know how avoid it. systemd's logging and management is necessary for system. I'm newbie, I will vote up when I can it ;) – hando han – 2019-02-18T07:59:55.727