im-config configuration ignored with gdm3

Bug #1720250 reported by Gunnar Hjalmarsson on 2017-09-28
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gdm3 (Ubuntu)
High
Unassigned
im-config (Ubuntu)
High
Gunnar Hjalmarsson

Bug Description

After having logged in via gdm3, the IM related environment variables are always set like this:

$ env | grep -E '_IM|XMOD'
QT_IM_MODULE=ibus
XMODIFIERS=@im=ibus

Changing ~/.xinputrc to e.g. xim makes no difference, so gdm3 prevents all other IM frameworks but IBus from working.

This problem seems to be similar to bug #1594681 (which was fixed).

Changed in im-config (Ubuntu):
importance: Undecided → High
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gdm3 (Ubuntu):
status: New → Confirmed
Changed in im-config (Ubuntu):
status: New → Confirmed
Mitsuya Shibata (cosmos-door) wrote :

My wayland session is same result.

Anyway, /usr/lib/systemd/user/im-config.service is installed, but systemctl doesn't show that unit file. Is it OK?

$ systemctl list-unit-files | grep im-config
(nothing)

Gunnar Hjalmarsson (gunnarhj) wrote :

@Mitsuya: I don't know systemd well enough to tell. What I did before drawing the conclusion that it's somehow gdm3 related was to install and test with lightdm. With lightdm the im-config variables are preserved also on GNOME shell (with or without Wayland).

Jeremy Bicha (jbicha) wrote :

Mitsuya, im-config provides a systemd *user* service. You'll need to use --user to see it like this:

$ systemctl --user list-unit-files | grep im-config

Mitsuya Shibata (cosmos-door) wrote :

> im-config provides a systemd *user* service.

Oh, sorry...

$ systemctl --user list-unit-files | grep im-config
im-config.service static
$ systemctl --user status im-config.service
● im-config.service - Launch and configure input method
   Loaded: loaded (/usr/lib/systemd/user/im-config.service; static; vendor preset: enabled)
   Active: inactive (dead)

Mitsuya Shibata (cosmos-door) wrote :

> With lightdm the im-config variables are preserved also on GNOME shell (with or without Wayland).

Umm...

With GDM3, Ubuntu.Xorg session correctly set GTK_IM_MODULE and other environments.
In this case, im-config will be launched from /etc/X11/Xsession.d/70im-config_launch.

If GTK_IM_MODULE and others is not be set on Wayland only,
I thought this will be caused by systemd service file.
However lightdm worked with Wayland, more need to be investigated further...

Mitsuya Shibata (cosmos-door) wrote :

Fist of all, I don't know details about history of upstart/unity
and user session system. There is no conclusion, just my research.

---

For Unity8/Mir, upstart script of im-config was added LP #1433831
This Ubuntu only script should be removed from im-config package.

Since switching user session from upstart to systemd, above upstart script
is convert to systemd unit on 0.29-1ubuntu14.

However this unit file uses initctl command, then this unit work on both of
systemd and upstart installed system only.

Legacy (Xorg) system will launches /etc/X11/Xsession.d/70im-config_launch
and set STARTUP variable to exec /usr/bin/im-launch.
All environment variables are set, no problem.

Wayland system doesn't exec /etc/X11/Xsession.d, i.e. any mechanism to
set environment variables is needed as like on Unity8/Mir.

(old) systemd unit doesn't work by two reasons.

  1. use initctl command of upstart
  2. bind to graphical-session.target which is not launched on ubuntu

If I understand correctly, graphical-session.target and graphical-session-pre.target
will be launched for unity8 system and others.
At artful, this target are not depended by any target and service.

/usr/lib/gnome-session/run-systemd-session will stop these targets,
but this script will be executed from unity.desktop only.

How about use basic.target instead of graphical-session.target?
I attach sample im-config.service.

sudo cp im-config.service /usr/lib/systemd/user/
systemctl --user daemon-reload
systemctl --user enable im-config.service
(and restart session by logout and login)

This service file will work about environment variables.

$ env | grep -E '_IM|XMOD'
CLUTTER_IM_MODULE=xim
QT4_IM_MODULE=xim
QT_IM_MODULE=ibus
XMODIFIERS=@im=ibus
GTK_IM_MODULE=ibus

However suggestion window will be displayed on top left of display,
not near cursor on gedit and gnome-termial. The reason isn't known.

Gunnar Hjalmarsson (gunnarhj) wrote :

Thanks, Mitsuya, for valuable input!

As regards the upstart stuff, it was introduced before Unity8, and since I don't know if all the flavors have switched to systemd for user session, I'm disinclined to drop it at this time.

I uploaded a test version of im-config here:

https://launchpad.net/~gunnarhj/+archive/ubuntu/im-config

The difference compared to the version in the queue is that I made use of your im-config.service script and changed the related symlink accordingly.

Even if the variables seem to be properly set, I made this observation:

$ systemctl --user list-unit-files | grep im-config
im-config.service disabled

Can't tell if that is of any significance.

Anyway, I'll try to make some experienced developer review this solution. It looks promising to me.

Jeremy Bicha (jbicha) wrote :

Gunnar, upstart has been removed from Debian 9 "Stretch" and from Ubuntu 17.10.

You should drop the debian/menu too.
https://lintian.debian.org/tags/command-in-menu-file-and-desktop-file.html

Gunnar Hjalmarsson (gunnarhj) wrote :

On 2017-10-02 00:00, Jeremy Bicha wrote:> Gunnar, upstart has been removed from Debian 9 "Stretch" and from
> Ubuntu 17.10.
Ah, had missed that.

> You should drop the debian/menu too.
I just uploaded a new version to the PPA with those changes.

Mitsuya Shibata (cosmos-door) wrote :

> I uploaded a test version of im-config here:

Thanks!

> Even if the variables seem to be properly set, I made this observation:
>
> $ systemctl --user list-unit-files | grep im-config
> im-config.service disabled

$ systemctl --user status im-config.service
● im-config.service - Launch and configure input method
   Loaded: loaded (/usr/lib/systemd/user/im-config.service; disabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2017-10-02 22:45:14 JST; 26min ago
 Main PID: 1266 (code=exited, status=0/SUCCESS)

10月 02 22:45:14 ubuntu-ax2 systemd[1260]: Starting Launch and configure input method...
10月 02 22:45:14 ubuntu-ax2 systemd[1260]: Started Launch and configure input method.

As my understand, user session unit is enabled by symlink on ~/.config/systemd/user/.
If there is not symlink on the directory, "is-enabled" command will show "disabled".
"/usr/lib/systemd/user" is vendor preset directory, and just show "vendor preset: enabled".

If you exec "systemctl --user preset", it will create symlink on ~/.config/systemd/user.

Mitsuya Shibata (cosmos-door) wrote :

Unfortunately, gnome-terminal and gedit show select window on top left...
(this behavior same as old im-config on wayland, not problem on xorg).

Mitsuya Shibata (cosmos-door) wrote :

Just for your information, I attached zesty's result about systemd.

Gunnar Hjalmarsson (gunnarhj) wrote :

On 2017-10-02 16:19, Mitsuya Shibata wrote:> As my understand, user session unit is enabled by symlink on
> ~/.config/systemd/user/. If there is not symlink on the directory,
> "is-enabled" command will show "disabled". "/usr/lib/systemd/user"
> is vendor preset directory, and just show "vendor preset: enabled".
>
> If you exec "systemctl --user preset", it will create symlink on
> ~/.config/systemd/user.
I think you misunderstood the nature of my observation. The modified package in the PPA works out of the box via the system level symlink:

/usr/lib/systemd/user/basic.target.wants/im-config.service

So no need to set a symlink in the users' HOME.

Maybe it's not a problem at all. I just noticed a difference.

> Unfortunately, gnome-terminal and gedit show select window on top
> left... (this behavior same as old im-config on wayland, not problem on
> xorg).
Ok. I first thought it was a side effekt of the new im-config.service file, but now I realize it's not. Then it's probably not related to im-config at all, but rather ibus/wayland/whatever.

Iain Lane (laney) wrote :

ok, I had a look at the unit

  - basic.target is quite basic, it happens for every user session. If the first session is a SSH login then we'll execute im-config when we probably shouldn't.
  - PartOf=graphical.target will be necessary when we get back to launching the UI under systemd (hopefully in 18.04), please don't drop it
  - Maybe this isn't a problem with basic.target, but it will be when we use graphical-session-pre.target - type=oneshot will mean that this is executed on every login
  - Same, maybe ok with basic.target --- there's no way to clear the variables and they won't be scoped to there being a graphical session (existing bug with the unit?)

Thought - what about putting a script in /etc/profile.d? basically doing what the unit would do, but make sure to case it on $XDG_CURRENT_DESKTOP being nonempty or something, so it doesn't run for shell logins.

Gunnar Hjalmarsson (gunnarhj) wrote :

As per Iain's suggestion I have uploaded a new variant to the PPA, where a file in /etc/profile.d replaces the modifications of im-config.service. It works AFAICT, but I'd appreciate your confirmation before I upload to the archive.

Mitsuya Shibata (cosmos-door) wrote :

> So no need to set a symlink in the users' HOME.
> Maybe it's not a problem at all. I just noticed a difference.

Yes, you are right. My old comment is just reason why "list-unit-files" show "disabled".

> Then it's probably not related to im-config at all, but rather ibus/wayland/whatever.

Filed as another bug #1721023

Mitsuya Shibata (cosmos-door) wrote :

Hi Ian and Gunnar,

Thank you for details about systemd target and new package!

The profile.d version works on my environment too with gedit (gtk app) and setup-mozc (qt app).
However suggestion window doesn't show up...

Gunnar Hjalmarsson (gunnarhj) wrote :

On 2017-10-03 15:16, Mitsuya Shibata wrote:
> The profile.d version works on my environment too with gedit (gtk
> app) and setup-mozc (qt app).

Ok..

> However suggestion window doesn't show up..

Confirmed. So then it doesn't work properly after all, right? (It does show up on "Ubuntu on Xorg", though.)

On Tue, Oct 03, 2017 at 01:16:54PM -0000, Mitsuya Shibata wrote:
> However suggestion window doesn't show up...

Please could you try to find out why this is?

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Gunnar Hjalmarsson (gunnarhj) wrote :
Gunnar Hjalmarsson (gunnarhj) wrote :
Gunnar Hjalmarsson (gunnarhj) wrote :

As Iain suggested on IRC

https://irclogs.ubuntu.com/2017/10/03/%23ubuntu-devel.html#t15:52

I checked out what the processes looked like for the two attempts at a solution, and attached a couple of files with my observations.

Well, not sure what I should look for, to be honest, but that exercise inspired me to a possible solution: Since gdm3 always starts ibus-daemon anyway, I added a condition to /usr/share/im-config/data/21_ibus.rc so im-config does not start ibus-daemon if gdm3 is the DM. That seems to fix it.

So I have uploaded yet another variant to the PPA.

https://launchpad.net/~gunnarhj/+archive/ubuntu/im-config

Iain Lane (laney) wrote :

On Wed, Oct 04, 2017 at 12:40:03AM -0000, Gunnar Hjalmarsson wrote:
> As Iain suggested on IRC
>
> https://irclogs.ubuntu.com/2017/10/03/%23ubuntu-devel.html#t15:52
>
> I checked out what the processes looked like for the two attempts at a
> solution, and attached a couple of files with my observations.
>
> Well, not sure what I should look for, to be honest, but that exercise
> inspired me to a possible solution: Since gdm3 always starts ibus-daemon
> anyway, I added a condition to /usr/share/im-config/data/21_ibus.rc so
> im-config does not start ibus-daemon if gdm3 is the DM. That seems to
> fix it.
>
> So I have uploaded yet another variant to the PPA.
>
> https://launchpad.net/~gunnarhj/+archive/ubuntu/im-config

Thanks Gunnar, good find.

I wonder what this is telling us - you end up with multiple copies of
iBus running or something? Or the order matters and somehow the
basic.target one starts up early enough and the other one doesn't?

From looking at that 21_ibus.rc script, it doesn't look like it's
crucial that im-config is the thing to actually execute iBus, right? If
that's the case, this is probably good. If it tests out, feel free to
upload.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Gunnar Hjalmarsson (gunnarhj) wrote :

I'm not able to spot the root cause for the problem with the ibus-mozc suggestion window, but I have tested on Ubuntu, Ubuntu on Xorg and Unity both with GDM and LightDM. The suggestion window failed to show up with the combination Wayland + LightDM, but that's an odd combo anyway, and the other tests were successful.

So I uploaded to the queue.

Changed in gdm3 (Ubuntu):
status: Confirmed → Invalid
Changed in im-config (Ubuntu):
assignee: nobody → Gunnar Hjalmarsson (gunnarhj)
status: Confirmed → Fix Committed
Mitsuya Shibata (cosmos-door) wrote :

My apologies for late and sparse reply...

> So I have uploaded yet another variant to the PPA.

Thank you for your upload. Suggestion window become to visible!

--

I will tackle following issues related to input method until 18.04 release.

- bug #1721023 : suggestion window position
- bug #1719938 : ibus-mozc isn't enabled by default on Japanese locale

Thanks!

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package im-config - 0.32-1ubuntu2

---------------
im-config (0.32-1ubuntu2) artful; urgency=medium

  * debian/input-method-config.sh, debian/rules:
    - Script which works around (in 17.10) the fact that
      graphical-session-pre.target services are not always run as
      intended (LP: #1720250).
  * debian/patches/dont-start-ibus-if-gdm3.patch:
    - Prevents two instances of ibus-daemon, which fixes issue with
      suggestion window not showing up when using ibus-mozc
      (LP: #1720250).
  * Dropped the upstart user session job.
  * debian/menu: Dropped.

 -- Gunnar Hjalmarsson <email address hidden> Wed, 04 Oct 2017 17:17:00 +0200

Changed in im-config (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers