Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing dead key layout, and Wayland problems #704

Closed
danielzgtg opened this issue Jan 23, 2023 · 7 comments
Closed

Confusing dead key layout, and Wayland problems #704

danielzgtg opened this issue Jan 23, 2023 · 7 comments

Comments

@danielzgtg
Copy link

danielzgtg commented Jan 23, 2023

Describe the bug

There should be a warning telling users to not select any keyboard layout with "intl" or "dead keys". The dead keys / compose / accents work, and only work, with the normal layout.

Some layouts don't work. They either type nothing, random accented letters, or luanma. They are as follows:

  • English (Dvorak, intl., with dead keys)
  • English (Dvorak, alt. intl.)
  • English (US, alt. intl.)
  • English (US, intl., with dead keys)

The following regular layouts work and the dead keys work in fcitx5:

  • Default
  • English (Dvorak)

To Reproduce
Steps to reproduce the behavior:

  1. Open fcitx5 in KDE settings
  2. Press "Select system layout"
  3. Select any dead keys or intl. layout
  4. Press "Ok"
  5. Notice there is no warning
  6. Spend 2 hours logging in and logging out, debugging why the dead keys don't work

Expected behavior

There should be a warning when the user tries to select a dead keys or intl. layout.
The user should be informed that those don't work.
With the warning they won't have to waste 2 hours debugging like me.

Here is my working configuration:

  • Group 1 in fcitx5 settings
  • Input Method Off with "Keyboard - English (US) - English (Dvorak)"
  • "Use new compose behavior" enabled in that keyboard's settings
  • System layout as "English (US) - English (Dvorak)"
  • "us, English (US), English (Dvorak), US flag" in KDE Keyboard Layouts
  • "Right Alt; Shift+Right Alt as Compose" in "3rd level shortcuts"
  • ("Right Alt" also works there but there is no compose. The only thing is that I had to change it away from "Right Alt never chooses 3rd level" to get dead keys to work)

Desktop (please complete the following information):

  • Desktop: (KDE, GNOME, etc): KDE Plasma 5.26.0, Frameworks 5.99.0, Qt 5.15.6
  • Display server type: X11, Wayland: Wayland
  • The output of fcitx5-diagnose if possible.
fcitx5-diagnose, with fcitx5 working like I want it to
# System Info:
1.  `uname -a`:

        Linux daniel-tablet1 6.1.6-surface #1 SMP PREEMPT_DYNAMIC Mon Jan 16 23:37:25 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

2.  `lsb_release -a`:

        No LSB modules are available.
        Distributor ID: Ubuntu
        Description:    Ubuntu 22.10
        Release:        22.10
        Codename:       kinetic

3.  `lsb_release -d`:

        Description:    Ubuntu 22.10

4.  `/etc/lsb-release`:

        DISTRIB_ID=Ubuntu
        DISTRIB_RELEASE=22.10
        DISTRIB_CODENAME=kinetic
        DISTRIB_DESCRIPTION="Ubuntu 22.10"

5.  `/etc/os-release`:

        PRETTY_NAME="Ubuntu 22.10"
        NAME="Ubuntu"
        VERSION_ID="22.10"
        VERSION="22.10 (Kinetic Kudu)"
        VERSION_CODENAME=kinetic
        ID=ubuntu
        ID_LIKE=debian
        HOME_URL="https://www.ubuntu.com/"
        SUPPORT_URL="https://help.ubuntu.com/"
        BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
        PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
        UBUNTU_CODENAME=kinetic
        LOGO=ubuntu-logo

6.  Desktop Environment:

    Desktop environment is `kde`.

7.  XDG SESSION TYPE:

        XDG_SESSION_TYPE='wayland'

8.  Bash Version:

        BASH_VERSION='5.2.2(1)-release'

# Environment:
1.  DISPLAY:

        DISPLAY=':0'


        WAYLAND_DISPLAY='wayland-0'

2.  Keyboard Layout:

    1.  `setxkbmap`:

            WARNING: Running setxkbmap against an XWayland server
            xkb_keymap {
                xkb_keycodes  { include "evdev+aliases(qwerty)" };
                xkb_types     { include "complete"      };
                xkb_compat    { include "complete"      };
                xkb_symbols   { include "pc+us+inet(evdev)"     };
                xkb_geometry  { include "pc(pc105)"     };
            };

    2.  `xprop`:

            _XKB_RULES_NAMES(STRING) = "evdev", "pc105", "us", "", ""

3.  Locale:

    1.  All locales:

            C
            C.utf8
            da_DK.utf8
            en_US.utf8
            fr_FR.utf8
            he_IL.utf8
            POSIX
            zh_TW.utf8

    2.  Current locale:

            LANG=en_US.UTF-8
            LANGUAGE=en
            LC_CTYPE="en_US.UTF-8"
            LC_NUMERIC=C
            LC_TIME=C
            LC_COLLATE="en_US.UTF-8"
            LC_MONETARY=C
            LC_MESSAGES="en_US.UTF-8"
            LC_PAPER=en_US.UTF-8
            LC_NAME=en_US.UTF-8
            LC_ADDRESS=en_US.UTF-8
            LC_TELEPHONE=en_US.UTF-8
            LC_MEASUREMENT=C
            LC_IDENTIFICATION=en_US.UTF-8
            LC_ALL=

4.  Directories:

    1.  Home:

            /home/home

    2.  `${XDG_CONFIG_HOME}`:

        Environment variable `XDG_CONFIG_HOME` is not set.

        Current value of `XDG_CONFIG_HOME` is `~/.config` (`/home/home/.config`).

    3.  Fcitx5 Settings Directory:

        Current fcitx5 settings directory is `~/.config/fcitx5` (`/home/home/.config/fcitx5`).

5.  Current user:

    The script is run as home (1000).

# Fcitx State:
1.  executable:

    Found fcitx5 at `/usr/bin/fcitx5`.

2.  version:

    Fcitx version: `5.0.18`

3.  process:

    Found 1 fcitx5 process:

           1663 fcitx5

4.  `fcitx5-remote`:

    `fcitx5-remote` works properly.

5.  DBus interface:

    Using `dbus-send` to check dbus.

    Owner of DBus name `org.fcitx.Fcitx5` is `:1.12`.

    PID of DBus name `org.fcitx.Fcitx5` owner is `1663`.

    Debug information from dbus:

           Input Context without group
          IC [8a7183ccf4774da2b2d2ba49176b1997] program:plasmashell frontend:dbus focus:0
          IC [fa997cdbe44145b39ff4781785369e16] program:firefox frontend:dbus focus:0
          IC [ad10e2b0d77947ac987e6b0353c4e3ca] program:firefox frontend:dbus focus:0
          IC [ab869c5b39b04c5ca44e7d60c3ef2d6c] program:firefox frontend:dbus focus:0
          IC [b443b795c2aa4a11b0010c32f8c8fe3a] program:firefox frontend:dbus focus:0
          IC [d646ddee090840d994a21b16125d805c] program:krunner frontend:dbus focus:0
          IC [111d1be0268842a48bb443b4dc6c11b6] program:kate frontend:dbus focus:0
          IC [d8f2717cedd54bf0acb1112ba49e362f] program:kate frontend:dbus focus:0
          IC [6dd0473aef3a4f948e0aab54c2df0eaf] program:firefox frontend:dbus focus:0
          IC [3ed8ef9d68f24eaf97278d14768aaeaa] program:firefox frontend:dbus focus:0
          IC [4021bffe158048cebd4f9f61630c5a01] program:firefox frontend:dbus focus:0
          IC [a82f3d6337c74178b14584c5c8b389fb] program:firefox frontend:dbus focus:0
          IC [4f5d05aa693049559cb83462002e001e] program:plasmashell frontend:dbus focus:0
          IC [f228e00b106c45b59bb50d86cf448488] program:plasmashell frontend:dbus focus:0
          IC [988d9b59cc0b4ad680420f98d8363276] program:kate frontend:dbus focus:0
          IC [6c0f0d3323e3499b8e701ba1aecc1633] program:konsole frontend:dbus focus:1

# Fcitx Configure UI:
1.  Config Tool Wrapper:

    Found fcitx5-configtool at `/usr/bin/fcitx5-configtool`.

2.  Config GUI for qt:

    **Config GUI for qt not found.**

3.  Config GUI for kde:

    Found fcitx5 kcm module.

        kcm_fcitx5                     - Configure Input Method

# Frontends setup:
## Xim:
1.  `${XMODIFIERS}`:

    Environment variable XMODIFIERS is set to "@im=fcitx" correctly.
    Xim Server Name from Environment variable is fcitx.

2.  XIM_SERVERS on root window:

    **Cannot find xim_server on root window.**

## Qt:
1.  qt4 - `${QT4_IM_MODULE}`:

    Environment variable QT_IM_MODULE is set to "fcitx" correctly.

2.  qt5 - `${QT_IM_MODULE}`:

    Environment variable QT_IM_MODULE is set to "fcitx" correctly.

3.  Qt IM module files:

    Found fcitx5 im module for qt5: `/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitx5platforminputcontextplugin.so`.
    Found unknown fcitx qt module: `/lib/x86_64-linux-gnu/qt5/plugins/kcms/kcm_fcitx5.so`.
    Found fcitx5 qt5 module: `/lib/x86_64-linux-gnu/fcitx5/qt5/libfcitx-quickphrase-editor5.so`.
    **Cannot find fcitx5 input method module for Qt4.**

## Gtk:
1.  gtk - `${GTK_IM_MODULE}`:

    Environment variable GTK_IM_MODULE is set to "fcitx" correctly.

2.  `gtk-query-immodules`:

    1.  gtk 2:

        **Cannot find `gtk-query-immodules` for gtk 2**

        **Cannot find fcitx5 im module for gtk 2.**

    2.  gtk 3:

        **Cannot find `gtk-query-immodules` for gtk 3**

        **Cannot find fcitx5 im module for gtk 3.**

3.  Gtk IM module cache:

    1.  gtk 2:

        Found immodules cache for gtk `2.24.33` at `/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules.cache`.
        Version Line:

            # Created by /usr/lib/x86_64-linux-gnu/libgtk2.0-0/gtk-query-immodules-2.0 from gtk+-2.24.33

        **Failed to find fcitx5 in immodule cache at `/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules.cache`**

        **Cannot find fcitx5 im module for gtk 2 in cache.**

    2.  gtk 3:

        Found immodules cache for gtk `3.24.34` at `/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules.cache`.
        Version Line:

            # Created by /usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0 from gtk+-3.24.34

        Found fcitx5 im modules for gtk `3.24.34`.

            "/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-fcitx5.so" 
            "fcitx" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 
            "fcitx5" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 

    3.  gtk 4:

        **Cannot find immodules cache for gtk 4**

        **Cannot find fcitx5 im module for gtk 4 in cache.**

4.  Gtk IM module files:

    1.  gtk 2:

        All found Gtk 2 immodule files exist.

    2.  gtk 3:

        All found Gtk 3 immodule files exist.

    3.  gtk 4:

        All found Gtk 4 immodule files exist.

# Configuration:
## Fcitx Addons:
1.  Addon Config Dir:

    Found fcitx5 addon config directory: `/usr/share/fcitx5/addon`.

2.  Addon List:

    1.  Found 19 enabled addons:

            Classic User Interface 5.0.18
            Clipboard 5.0.18
            DBus 5.0.18
            DBus Frontend 5.0.18
            Fcitx4 Frontend 5.0.18
            Hangul 5.0.10
            IBus Frontend 5.0.18
            Input method selector 5.0.18
            Keyboard 5.0.18
            Mozc 
            Status Notifier 5.0.18
            Notification 5.0.18
            Rime 5.0.14
            Spell 5.0.18
            Unicode 5.0.18
            Wayland 5.0.18
            Wayland Input method frontend 5.0.18
            XCB 5.0.18
            X Input Method Frontend 5.0.18

    2.  Found 1 disabled addons:

            KDE Input Method Panel 5.0.18

3.  Addon Libraries:

    All libraries for all addons are found.

4.  User Interface:

    Found 1 enabled user interface addons:

        Classic User Interface

## Input Methods:
1.  `/home/home/.config/fcitx5/profile`:

        [Groups/0]
        # Group Name
        Name=Q
        # Layout
        Default Layout=us
        # Default Input Method
        DefaultIM=keyboard-us

        [Groups/0/Items/0]
        # Name
        Name=keyboard-us
        # Layout
        Layout=

        [Groups/1]
        # Group Name
        Name=K
        # Layout
        Default Layout=us
        # Default Input Method
        DefaultIM=hangul

        [Groups/1/Items/0]
        # Name
        Name=hangul
        # Layout
        Layout=us

        [Groups/2]
        # Group Name
        Name=Z
        # Layout
        Default Layout=us
        # Default Input Method
        DefaultIM=rime

        [Groups/2/Items/0]
        # Name
        Name=rime
        # Layout
        Layout=us

        [Groups/3]
        # Group Name
        Name=J
        # Layout
        Default Layout=jp-us
        # Default Input Method
        DefaultIM=mozc

        [Groups/3/Items/0]
        # Name
        Name=mozc
        # Layout
        Layout=jp-us

        [Groups/4]
        # Group Name
        Name="Group 1"
        # Layout
        Default Layout=us-dvorak
        # Default Input Method
        DefaultIM=keyboard-us-dvorak

        [Groups/4/Items/0]
        # Name
        Name=keyboard-us-dvorak
        # Layout
        Layout=

        [GroupOrder]
        0=Q
        1=J
        2=Z
        3="Group 1"
        4=K

# Log:
1.  `date`:

        Sun Jan 22 21:19:01 EST 2023

2.  `/home/home/.config/fcitx5/crash.log`:

    `/home/home/.config/fcitx5/crash.log` not found.

**Warning: the output of fcitx5-diagnose contains sensitive information, including the distribution name, kernel version, name of currently running programs, etc.**

**Though such information can be helpful to developers for diagnostic purpose, please double check and remove as necessary before posting it online publicly.**
@wengxt
Copy link
Member

wengxt commented Jan 23, 2023

Can you explain which setup doesn't work for you?

With the key you tried to press and what's the output.

Also, fcitx will populate layout to kde keyboard settings, so please don't change any layout in kde keyboard settings (keyboard option is ok).

If it doesn't work, it should be fixed, instead of adding "warning".

@danielzgtg
Copy link
Author

All the following examples will use the same test sequence, 'RAlt + ' + [aoeui], RAlt + ` + [aoeui], RAlt + , + c". Here is my working configuration as described in the original post:

image

Broken, and fcitx5 should warn about: "intl. with dead keys" types the extra apostrophe when trying to type the accents:

image

Broken, and fcitx5 should warn about: "intl. with dead keys" with KDE's right alt disabled fixes the apostrophe problem, but I need to type a cedilla for French:

image

Broken, and fcitx5 should warn about: "alt. intl." gives me random accents:

image

Those alternative layout sometime also mess with my normal typing of the quotation mark and apostrope without RAlt held down. This makes it hard for me to code.

Also, fcitx will populate layout to kde keyboard settings

That stopped working ever since I switched from X11 to Wayland. No input method, whether fcitx5 or ibus can change KDE's keyboard layout. Freedesktop/KDE still needs to provide an API for that.

, so please don't change any layout in kde keyboard settings

image

It is impossible for me to type Chinese, or Japanese Kana without changing it in KDE. I use Dvorak for English & French, and a modified QWERTY with Windows/Alt/Menu keys remapped to Henkan for Chinese & Japanese & Korean. fcitx5 worked on X11, but has always failed to switch my layout from Dvorak to QWERTY on Wayland. Every time I switch languages, I need to use both CTRL+ESC to switch fcitx5, and click on the KDE keyboard layout icon in the taskbar (there are two "jp" icons that always show the same thing, except only the left one has the bouncing animation on click, oh well). The layouts I configured in fcitx5 have always been ignored on Wayland.

The Wayland problem should be discussed in a different issue on GitHub. The problem is probably on Freedesktop/KDE's end and not fcitx5's. While it is inconvenient, I was able to find a workaround quickly compared to this issue about dead keys / intl compose layout problem.

@wengxt
Copy link
Member

wengxt commented Jan 23, 2023

I think you have some misunderstanding about dead key, so basically, dead key doesn't need a leading compose key.

So if your layout is US. intl, ' + a will directly gives you á. The ' key will produce dead_acute, instead of acute, this makes compose works differently.

To learn about Compose sequence, check /usr/share/X11/locale/en_US.UTF-8/Compose on your system.

For example, there is (<Multi_Key> is what usually referred as "Compose key")

<Multi_key> <acute> <A>  "Á" Aacute # LATIN CAPITAL LETTER A WITH ACUTE

But there is no

<Multi_key> <dead_acute> <A>  "Á" Aacute # LATIN CAPITAL LETTER A WITH ACUTE

Instead, there is

<dead_acute> <A>  "Á" Aacute # LATIN CAPITAL LETTER A WITH ACUTE

If you want to customize any compose sequence, you may use ~/.XCompose .

The next thing, you don't need to configure kde layout. That will confuse fcitx's layout functionality under KDE.

Fcitx even allow you to set the layout for certain input method, so you don't need to mess with the kde's layout.

Switching group can be used just like switching layout under KDE.

Based on what you describe, you can do things like

[Groups/0]
# Group Name
Name=f
# Layout
Default Layout=us-intl
# Default Input Method
DefaultIM=keyboard-fr-dvorak

[Groups/0/Items/0]
# Name
Name=keyboard-us-dvorak
# Layout
Layout=

[Groups/0/Items/1]
# Name
Name=keyboard-fr-dvorak
# Layout
Layout=

[Groups/0/Items/2]
# Name
Name=mozc
# Layout
Layout=jp

[GroupOrder]
0=f

图片

Two group like this

[Groups/0]
# Group Name
Name=;
# Layout
Default Layout=jp
# Default Input Method
DefaultIM=mozc

[Groups/0/Items/0]
# Name
Name=mozc
# Layout
Layout=

[Groups/1]
# Group Name
Name=f
# Layout
Default Layout=us-dvorak
# Default Input Method
DefaultIM=keyboard-fr-dvorak

[Groups/1/Items/0]
# Name
Name=keyboard-us-dvorak
# Layout
Layout=

[Groups/1/Items/1]
# Name
Name=keyboard-fr-dvorak
# Layout
Layout=

[GroupOrder]
0=;
1=f

If your jp-us layout is coming from your own customized xkb config, you can follow this to make fcitx recognize it, manually hack the profile (quit fcitx first, then change Layout=jp-us) may also work.
https://www.csslayer.info/wordpress/fcitx-dev/how-to-use-a-missing-keyboard-layout-in-fcitx-5/

Reading .xml from ~/.config/xkb is only added recently df632d7 , so you may prefer the method in the blog post above.

@danielzgtg
Copy link
Author

manually hack the profile

My Japanese layout was automatically switching on X11, but Wayland broke it and made it manual-only. The accents for French I never tried on X11.

The next thing, you don't need to configure kde layout. That will confuse fcitx's layout functionality under KDE.

Can you test this on KDE Wayland yourself? fcitx5 fails to automatically change the keyboard layout, and I always have to do it manually on Wayland:

2023-01-22.23-45-58.mp4

I think you have some misunderstanding about [...] works differently.

Thank you for this information. If I had seen it earlier, perhaps somewhere in the documentation, I would have saved 1 hour.

However, I need the cedilla so I can't use the dead keys layout.

@wengxt
Copy link
Member

wengxt commented Jan 23, 2023

It definitely works here.

Actually after check your diagnose output again, I find your fcitx5 didn’t open a wayland connection. That’s probably the layout setting code in wayland module doesn’t work.

I’m not sure if it’s relevant to how your fcitx starts, can you tell me more about that?

@wengxt
Copy link
Member

wengxt commented Jan 23, 2023

Basically, the debuginfo part, should look like this

   Group [x11::1] has 0 InputContext(s)
Group [wayland:] has 9 InputContext(s)   
  IC [1a2baa5c5f884d819cc684242c4d402b] program:firefox frontend:dbus cap:6001000032 focus:0
  IC [8b213832a1364db2b38d4e39b35dbd93] program:plasmashell frontend:dbus cap:1e001800072 focus:0
  IC [97afc8f99b8a423fb582a2e349fe8a5b] program:firefox frontend:dbus cap:e001000032 focus:0
  IC [33db0a078f7444fea392a9e7e6431125] program:krunner frontend:dbus cap:1e001820072 focus:0
  IC [8fef766bef334000936ca09f09c5e015] program:firefox frontend:dbus cap:e001000072 focus:0
  IC [16f2bd1166964401a8dadd764486b663] program:spectacle frontend:dbus cap:1e001800072 focus:0
  IC [0dd5907ffd914023bf9ac91696a92786] program:konsole frontend:dbus cap:e001800072 focus:1
  IC [94843195c5e74fb8bcf6b2f6dc259efc] program:firefox frontend:dbus cap:6001000032 focus:0
  IC [ddf6c678079d4813ace0568e07b46110] program:kwrite frontend:dbus cap:1e001800072 focus:0
Input Context without group

In your case, it's all "Input Context without group", which means wayland connection is not there and definitely the code here doesn't run:

if (!isKDE5() || !isWaylandSession_ || !*config_.allowOverrideXKB) {

Which is the code that set layout under wayland KDE.

@danielzgtg danielzgtg changed the title Need a warning to not select dead keys layout for compose to work Confusing dead key layout, and Wayland problems Jan 28, 2023
danielzgtg added a commit to danielzgtg/linuxenv that referenced this issue Jan 28, 2023
This took 10 hours of debugging.
Details will be at fcitx/fcitx5#704
It took so many logins and killall5s, reading various scripts' source
codes, looking in /proc/pid/environ and /proc/pid/fd, ldd+strings+rg,
installing and setting up auditd, systemctl --user show, and general
frustration.

It turns out fcitx5 can be started from 3 places: im-config, .desktop
autostarts, systemd user autostarts, and kwin wayland, and they
conflict with each other.
In the end I chose to let kwin_wayland handle it, and now fcitx5 is
detecting Wayland properly.
@danielzgtg
Copy link
Author

I finally fixed my fcitx5 startup. I turns out im-config was messing with things, and I had to disable it and use kwin_wayland to start my fcitx5. I performed the changes in danielzgtg/linuxenv@d594567 . It detects KDE Wayland now and is able to control the keyboard settings. Your waylandmodule.cpp is a very creative solution I would have never thought of. Unfortunately with fcitx5 in control of my keyboard, my Henkan key stopped working again, and I will create a new issue for a feature I want that will fix it.

Debugging details

At first I thought the wayland support wasn't complied into my distro's fcitx5. I did bingrep, strings | rg, and ldd on my fcitx5 executable. I couldn't find any wayland strings. Then I looked at the file organization in this GitHub repository, and found the multiple levels CMakeLists.txt, and they indicated Wayland support is a separate module. I found the module installed as dpkg-query -L fcitx5-module-wayland. I checked in fcitx5 KDE settings, and the Wayland module was checked. In the source code I see allowOverrideXKB, but the only xkb I could rg in ~/.config/fcitx5 was OverrideXkbOption=False. It's false, but Wayland works after restarting fcitx5, therefore my options are configured as they should.

So you asked about how my fcitx5 was started. I didn't really know either. I had a file in ~./config/autostart, and I wrongly thought that one was working. I had a bug in that file in that I was telling fcitx5 to fork with -d, something that systemd doesn't like, so I was ignoring the red error in systemd --user because I was planning to fix it later.

I had a fcitx5 -d process running. At this point I didn't know it was not from my autostart file, but rather from im-launch. I did exa -alF /proc/pid/fd:

lr-x------  64 home 28 Jan 16:33 0 -> /dev/null
l-wx------  64 home 28 Jan 16:33 1 -> /dev/null
l-wx------  64 home 28 Jan 16:33 2 -> /dev/null
lr-x------  64 home 28 Jan 16:33 3 -> pipe:[109734]
l-wx------  64 home 28 Jan 16:33 4 -> pipe:[109734]
lrwx------  64 home 28 Jan 16:33 5 -> anon_inode:[eventpoll]
lrwx------  64 home 28 Jan 16:33 6 -> anon_inode:[timerfd]
lrwx------@ 64 home 28 Jan 16:33 7 -> socket:[103920]
lrwx------@ 64 home 28 Jan 16:33 8 -> socket:[106210]
lrwx------@ 64 home 28 Jan 16:33 9 -> socket:[108714]
lrwx------@ 64 home 28 Jan 16:33 10 -> socket:[108718]
lrwx------@ 64 home 28 Jan 16:33 28 -> socket:[103921]
lrwx------@ 64 home 28 Jan 16:33 29 -> socket:[103923]
lrwx------@ 64 home 28 Jan 16:33 30 -> socket:[103924]

I then restarted fcitx5 with fcitx5 -r:

lrwx------  64 home 28 Jan 16:33 0 -> /dev/pts/2
lrwx------  64 home 28 Jan 16:33 1 -> /dev/pts/2
lrwx------  64 home 28 Jan 16:33 2 -> /dev/pts/2
lr-x------  64 home 28 Jan 16:33 3 -> pipe:[110316]
lrwx------@ 64 home 28 Jan 16:33 4 -> socket:[107902]
lrwx------@ 64 home 28 Jan 16:33 5 -> socket:[107903]
lrwx------  64 home 28 Jan 16:33 6 -> /run/user/1000/wayland-0.lock
lrwx------@ 64 home 28 Jan 16:33 7 -> socket:[107904]
lrwx------@ 64 home 28 Jan 16:33 8 -> socket:[107905]
lrwx------@ 64 home 28 Jan 16:33 9 -> socket:[107906]
l-wx------  64 home 28 Jan 16:33 10 -> pipe:[110316]
lrwx------  64 home 28 Jan 16:33 11 -> anon_inode:[eventpoll]
lrwx------  64 home 28 Jan 16:33 12 -> anon_inode:[timerfd]
lrwx------@ 64 home 28 Jan 16:33 13 -> socket:[108657]
lrwx------@ 64 home 28 Jan 16:33 14 -> socket:[108658]
lrwx------@ 64 home 28 Jan 16:33 15 -> socket:[110317]
lrwx------@ 64 home 28 Jan 16:33 16 -> socket:[110328]
lrwx------  64 home 28 Jan 16:33 21 -> anon_inode:[timerfd]
lr-x------  64 home 28 Jan 16:33 36 -> pipe:[110318]
l-wx------  64 home 28 Jan 16:33 37 -> pipe:[110318]
lr-x------  64 home 28 Jan 16:33 38 -> pipe:[110319]
l-wx------  64 home 28 Jan 16:33 39 -> pipe:[110319]
lrwx------@ 64 home 28 Jan 16:33 40 -> socket:[110320]
lrwx------  64 home 28 Jan 16:33 41 -> anon_inode:[eventpoll]
lrwx------@ 64 home 28 Jan 16:33 42 -> socket:[110321]
lrwx------@ 64 home 28 Jan 16:33 43 -> socket:[112785]
lrwx------@ 64 home 28 Jan 16:33 44 -> socket:[112786]
lrwx------@ 64 home 28 Jan 16:33 45 -> socket:[112787]
lr-x------  64 home 28 Jan 16:33 46 -> pipe:[109011]
l-wx------  64 home 28 Jan 16:33 47 -> pipe:[109011]
lr-x------  64 home 28 Jan 16:33 48 -> pipe:[109012]
lrwx------@ 64 home 28 Jan 16:33 49 -> socket:[109819]
l-wx------  64 home 28 Jan 16:33 50 -> pipe:[109012]
lrwx------  64 home 28 Jan 16:33 51 -> anon_inode:[eventpoll]
lrwx------@ 64 home 28 Jan 16:33 53 -> socket:[109821]

Interesting. There is a difference. I was thinking it might be a difference between fcitx5 -r and fcitx5 -d, so I pressed CTRL+C at the terminal and ran fcitx5 -d instead:


lrwx------  64 home 28 Jan 16:34 0 -> /dev/pts/2
lrwx------  64 home 28 Jan 16:34 1 -> /dev/pts/2
lrwx------  64 home 28 Jan 16:34 2 -> /dev/pts/2
lr-x------  64 home 28 Jan 16:34 3 -> pipe:[104348]
lrwx------@ 64 home 28 Jan 16:34 4 -> socket:[107902]
lrwx------@ 64 home 28 Jan 16:34 5 -> socket:[107903]
lrwx------  64 home 28 Jan 16:34 6 -> /run/user/1000/wayland-0.lock
lrwx------@ 64 home 28 Jan 16:34 7 -> socket:[107904]
lrwx------@ 64 home 28 Jan 16:34 8 -> socket:[107905]
lrwx------@ 64 home 28 Jan 16:34 9 -> socket:[107906]
l-wx------  64 home 28 Jan 16:34 10 -> pipe:[104348]
lrwx------  64 home 28 Jan 16:34 11 -> anon_inode:[eventpoll]
lrwx------  64 home 28 Jan 16:34 12 -> anon_inode:[timerfd]
lrwx------@ 64 home 28 Jan 16:34 13 -> socket:[108657]
lrwx------@ 64 home 28 Jan 16:34 14 -> socket:[108658]
lrwx------@ 64 home 28 Jan 16:34 15 -> socket:[112862]
lrwx------@ 64 home 28 Jan 16:34 17 -> socket:[108359]
lrwx------  64 home 28 Jan 16:34 19 -> anon_inode:[timerfd]
lr-x------  64 home 28 Jan 16:34 36 -> pipe:[107389]
l-wx------  64 home 28 Jan 16:34 37 -> pipe:[107389]
lr-x------  64 home 28 Jan 16:34 38 -> pipe:[107390]
l-wx------  64 home 28 Jan 16:34 39 -> pipe:[107390]
lrwx------@ 64 home 28 Jan 16:34 40 -> socket:[107391]
lrwx------  64 home 28 Jan 16:34 41 -> anon_inode:[eventpoll]
lrwx------@ 64 home 28 Jan 16:34 42 -> socket:[107392]
lrwx------@ 64 home 28 Jan 16:34 43 -> socket:[112863]
lrwx------@ 64 home 28 Jan 16:34 44 -> socket:[112864]
lrwx------@ 64 home 28 Jan 16:34 45 -> socket:[108356]
lr-x------  64 home 28 Jan 16:34 46 -> pipe:[112865]
l-wx------  64 home 28 Jan 16:34 47 -> pipe:[112865]
lr-x------  64 home 28 Jan 16:34 48 -> pipe:[112866]
lrwx------@ 64 home 28 Jan 16:34 49 -> socket:[109819]
l-wx------  64 home 28 Jan 16:34 50 -> pipe:[112866]
lrwx------  64 home 28 Jan 16:34 51 -> anon_inode:[eventpoll]
lrwx------@ 64 home 28 Jan 16:34 53 -> socket:[109821]

So, there is no difference in opened file descriptors between the two flags. I then did killall5, and ran cat /proc/pid/environ | sd "\u0000" '\n' | sort after logging in, then again with the restarted fcitx5. Here is the difference in the environments:

--- before      2023-01-28 19:04:40.736842014 -0500
+++ after       2023-01-28 19:04:35.576806458 -0500
@@ -1,13 +1,18 @@
 ANDROID_SDK_ROOT=/home/home/Android/Sdk/
 CCACHE_DIR=/home/home/.ccache
 CLUTTER_IM_MODULE=xim
+COLORFGBG=15;0
+COLORTERM=truecolor
 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
-DEBUGINFOD_URLS=https://debuginfod.ubuntu.com 
+DEBUGINFOD_URLS=https://debuginfod.ubuntu.com
 DEFAULTS_PATH=/usr/share/gconf/plasmawayland.default.path
 DESKTOP_SESSION=plasmawayland
+DISPLAY=:0
 DOTNET_CLI_TELEMETRY_OPTOUT=1
 EGL_PLATFORM=wayland
 GCC_COLORS=error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01
+GDK_DPI_SCALE=1
+GDK_SCALE=1
 GDM_LANG=en
 GDMSESSION=plasmawayland
 GLFW_IM_MODULE=ibus
@@ -17,23 +22,37 @@
 GTK_MODULES=gail:atk-bridge
 GTK_USE_PROFILE=1
 HOME=/home/home
-IM_CONFIG_PHASE=2
+IM_CONFIG_CHECK_ENV=1
+IM_CONFIG_PHASE=1
+INVOCATION_ID=a1d380514378477b93606667b714910c
+JOURNAL_STREAM=8:117271
+KDE_APPLICATIONS_AS_SCOPE=1
+KDE_FULL_SESSION=true
+KDE_SESSION_UID=1000
+KDE_SESSION_VERSION=5
+KGLOBALACCELD_PLATFORM=org.kde.kwin
+KONSOLE_DBUS_SERVICE=:1.98
+KONSOLE_DBUS_SESSION=/Sessions/1
+KONSOLE_DBUS_WINDOW=/Windows/1
+KONSOLE_VERSION=220802
 LANG=en_US.UTF-8
 LANGUAGE=en
 LC_ADDRESS=en_US.UTF-8
 LC_IDENTIFICATION=en_US.UTF-8
-LC_MEASUREMENT=en_US.UTF-8
-LC_MONETARY=en_US.UTF-8
+LC_MEASUREMENT=C
+LC_MONETARY=C
 LC_NAME=en_US.UTF-8
-LC_NUMERIC=en_US.UTF-8
+LC_NUMERIC=C
 LC_PAPER=en_US.UTF-8
 LC_TELEPHONE=en_US.UTF-8
-LC_TIME=en_US.UTF-8
+LC_TIME=C
 LESSCLOSE=/usr/bin/lesspipe %s %s
 LESSHISTFILE=/dev/null
 LESSHISTSIZE=0
 LESSOPEN=| /usr/bin/lesspipe %s
 LOGNAME=home
+LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
+MANAGERPID=18181
 MANDATORY_PATH=/usr/share/gconf/plasmawayland.mandatory.path
 MANPAGER=sh -c 'col -bx | bat -l man -p'
 MOZ_ENABLE_WAYLAND=1
@@ -42,15 +61,31 @@
 NVM_DIR=/home/home/.nvm
 PAPERSIZE=letter
 PATH=/home/home/bin:/home/home/.cargo/bin:/home/home/kde/src/kdesrc-build:/home/home/.cabal/bin:/home/home/.ghcup/bin:/home/home/.local/bin:/home/home/.nvm/versions/node/v19.5.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/home/.dotnet/tools
+PLASMA_USE_QT_SCALING=1
+PROFILEHOME=
 PWD=/home/home
+QSG_RENDER_LOOP=basic
 QT_ACCESSIBILITY=1
+QT_AUTO_SCREEN_SCALE_FACTOR=0
 QT_IM_MODULE=fcitx
+QT_WAYLAND_FORCE_DPI=96
 SAL_USE_VCLPLUGIN=kde
 SDL_IM_MODULE=fcitx
 SHELL=/bin/bash
-SHLVL=0
+SHELL_SESSION_ID=c2ffdf40a89e4668a18568dc3d4eec46
+SHLVL=1
+SYSTEMD_EXEC_PID=18372
+TERM=xterm-256color
+TEXTDOMAIN=lightdm
 USER=home
-XDG_CONFIG_DIRS=/etc/xdg/xdg-plasmawayland:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings
+_=/usr/bin/fcitx5
+WAYLAND_DISPLAY=wayland-0
+WINDOWID=1
+XAUTHORITY=/run/user/1000/xauth_OPxJVO
+XCURSOR_SIZE=24
+XCURSOR_THEME=breeze_cursors
+XDG_ACTIVATION_TOKEN=kwin-2
+XDG_CONFIG_DIRS=/home/home/.config/kdedefaults:/etc/xdg/xdg-plasmawayland:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings
 XDG_CURRENT_DESKTOP=KDE
 XDG_DATA_DIRS=/usr/share/plasmawayland:/usr/local/share/:/usr/share/
 XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/home
@@ -63,4 +98,8 @@
 XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session2
 XDG_SESSION_TYPE=wayland
 XDG_VTNR=8
+XKB_DEFAULT_LAYOUT=us
+XKB_DEFAULT_MODEL=pc105
+XKB_DEFAULT_OPTIONS=lv3:ralt_alt
+XKB_DEFAULT_VARIANT=dvorak
 XMODIFIERS=@im=fcitx

So WAYLAND_DISPLAY wasn't getting set for some reason. That explains why fcitx5 wasn't opening a file descriptor for wayland. Also, fcitx5 started being able to control my keyboard layout only after it is restarted after logging in. That is strange.

I've previously had environment variable problems before when using autostart. There are lots of edge cases about which variables systemd/dbus set and when. A KDE last year or sometime may have fixed it, but I continued with the next step. I rewrote my ~/.config/autostart/ file as a ~/.config/systemd/user service and enabled it. I was no longer passing -d, and I was telling it to start before/after certain KDE user services. I did killall5 and logged back in, and experienced a shock.

fcitx5 -d was still there. I did another killall5 and made sure it was a different pid, but it popped up again. Wayland was still broken, and I clearly didn't add the -d. I looked at systemctl --user status my_service_name && journalctl --user -r, and was confused when I saw "Failed to create addon: dbus Unable to request dbus name. Is there another fcitx already running?". I then discovered kwin_wayland has a way of starting fcitx5. It's in "System Settings > Input Devices > Virtual Keyboard > None/Fcitx 5". I switched a few times between that and the systemd user service solution but the fcitx5 -d was still there.

Then I realized it was strange that the fcitx5 -d process had a parent pid of 1. I expect autostarted processes in modern desktop environments to have systemd --user as their parent and not fork, or in this case have kwin_wayland as their parent. I looked through everything in my ~/.config, /etc/, and ~/.local/share directories to look for what could be starting it, only to find nothing. Normally strace could be used to track startup, but this time it's too closely linked with me needing to log into my desktop first in order to start my debugging, and even if I used the TTY, systemd --user would have been started. So I remembered there was an audit system in Linux. I did apt install auditd && auditctl -a always,exit -F arch=bin32 -S execve -S clone -S clone3 && auditctl -a always,exit -F arch=bin64 -S execve -S clone -S clone3. I did killall5 and logged in again, then inspected the logged data with ausearch -i.

What I found was slightly disturbing. There was the fcitx5 I was configured to start myself, but something else was starting fcitx5 -d before. I traced the ppid chain up, and it looked like it was some kind of shell script using dash. There was a bit of xkb-related noise surrounding it. It was doing dpkg-query -l ibus, dpkg-query -l fcitx-bin, and query-query -l fcitx5, which is quite inefficient and strange. I was wondering whether it was logging a command I entered myself, but I only use dpkg-query -L, not dpkg-query -l. At the top I found commands that included the words im-launch, plasma-dbus-run-session-if-needed, and startplasma-wayland. This seems to be happened very early and just as my display manager starts my desktop environment. I remember needing to run im-config back when I was using Ubuntu on compiz, but I never ran it on this computer. It seems like that package is messing with my IME startup.

After running im-config and selecting "do not activate any IM from im-config and use desktop default", the wrongly started fcitx5 -d process was finally gone. I used type im-config; file /usr/bin/im-config; bat /usr/bin/im-config; bat /usr/share/im-config/im-config.common and read the code to determine that .xinputrc is the only file that matters for im-config. I wanted to do apt purge im-config but it said it would remove ubuntu-desktop, which I don't really want to remove just in case I want to test stuff on GNOME later, even though I only use KDE.

In the end, I decided to give kwin_wayland the job of starting fcitx5, as that seems to be the most maintained and supported way. I disabled the xdg, systemd user, and im-config autostarts. Now fcitx5 detects and controls my KDE Wayland successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants