You are not logged in.

#1 2014-07-31 12:33:19

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Creating an IBus systemd service file

I currently start ibus-daemon with the following in my ~/.xprofile:

ibus-daemon --daemonize --xim

The thing is this does not display very nicely in the output of `systemctl status`; there're several ibus related processes listed, all in the same process Group ID. I figure if I write an ibus.service and manage it with systemctl, they would be grouped together in the output of `systemctl status`, correct?

In any case, I'm trying to write an IBus systemd service file. What I have so far:

[Unit]
Description=Intelligent Input Bus
Documentation=man:ibus-daemon(1)

[Service]
Type=dbus
BusName=org.freedesktop.IBus
ExecStart=/usr/bin/ibus-daemon --replace --xim --panel disable
ExecReload=/usr/bin/ibus restart
ExecStop=/usr/bin/ibus exit

[Install]
WantedBy=default.target

I put the above in file ~/.config/systemd/user/ibus.service and tried

% systemctl --user start ibus.service

For 90 seconds the command didn't return. In that time, ibus-daemon was in fact started, I used the command `ibus` to check that the Bus part was working normally. 90 seconds later systemd bailed out,

Job for ibus.service failed. See 'systemctl status ibus.service' and 'journalctl -xn' for details.

Nothing useful in the journal, really,

systemd[388]: Starting Intelligent Input Bus...
systemd[388]: ibus.service start operation timed out. Terminating.
systemd[388]: Failed to start Intelligent Input Bus.
systemd[388]: Unit ibus.service entered failed state.

What was not working during the 90 seconds was I couldn't actually use IBus to input anyting. I was able to switch engines with `ibus engine <foo>` but if then I started typing IBus was not used at all.

Compare the process tree between manually running ibus-daemon and using systemctl start,

ibus-daemon --replace --xim --panel disable
----
systemd,1,1
  |-gnome-terminal-,485,440
  |   |-zsh,7299,7299
  |   |   `-ibus-daemon,9732,9732 --replace --xim --panel disable
  |   |       |-ibus-dconf,9736,9732
  |   |       |   |-{dconf worker},9743,9732
  |   |       |   |-{gdbus},9742,9732
  |   |       |   `-{gmain},9740,9732
  |   |       |-{gdbus},9739,9732
  |   |       `-{gmain},9733,9732
  `-ibus-x11,9738,9732 --kill-daemon
      |-{gdbus},9746,9732
      `-{gmain},9745,9732
systemctl --user start ibus
----
systemd,1,1
  `-systemd,388,388 --user
      |-(sd-pam),390,388  
      `-ibus-daemon,9911,9911 --replace --xim --panel disable
          |-ibus-dconf,9914,9911
          |   |-{dconf worker},9921,9911
          |   |-{gdbus},9919,9911
          |   `-{gmain},9917,9911
          |-{gdbus},9920,9911
          |-{gmain},9912,9911
          `-{pool},9926,9911

I see two differences: 1) ibus-x11 is present only if ibus-daemon is run manually; 2) Note the {pool} process in the systemctl case.

UPDATE²
ibus-x11 will fail to start silently if the DISPLAY env is not set, which is the case in the systemd env. Damn. When I set Environment="DISPLAY=:0" ibus-x11 is started just fine.
So the question remaining here, is why Type=dbus does not work?


I also tried to comment use Type=simple without BusName= to the same result.
UPDATE
I forgot to systemctl daemon-reload!
With Type=simple ibus-daemon *is* started. BUT, ibus-x11, which is supposed to be started with the --xim option, is not started. I guess it's because it forks? I'll try something.


I do feel it should be Type=dbus though, and I also found a file, part of the gnome-settings-daemon package, /usr/share/dbus-1/services/org.freedesktop.IBus.service with the content:

[D-BUS Service]
Name=org.freedesktop.IBus
Exec=/usr/bin/ibus-daemon --replace --xim --panel disable

Any idea how to make systemd happy?

Last edited by lolilolicon (2014-07-31 14:10:37)


This silver ladybug at line 28...

Offline

#2 2014-07-31 15:19:10

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: Creating an IBus systemd service file

The first post is too long... Let me update the status with a new post.

The user service file currently looks like this:

# ibus@.service

[Unit]
Description=Intelligent Input Bus
Documentation=man:ibus-daemon(1)

[Service]
Environment="DISPLAY=%I"
ExecStart=/usr/bin/ibus-daemon --replace --xim --panel disable
ExecReload=/usr/bin/ibus restart
ExecStop=/usr/bin/ibus exit

[Install]
WantedBy=default.target

And you can enable it for the current DISPLAY via

% systemctl --user enable "ibus@$DISPLAY.service"

DISPLAY must be set for the --xim option to work.
According to systemd.exec(5), "processes started by user systemd instances inherit all environment variables from the user systemd instance". But at the time the user systemd instance is started, the DISPLAY env is not set yet, so I'm using the %I place holder here.

Although there doesn't seem to be much benefit, I still wonder why Type=dbus doesn't work. Is systemd looking for the wrong bus?


This silver ladybug at line 28...

Offline

Board footer

Powered by FluxBB