Installing on Arch Wayland

I was hoping someone might be able to give some pointers about where to look for next steps. I run a Manjaro machine using Wayland sessions, which has become a bit of an issue. Keyman v 16.0.144-1 is available via the Arch User Repository, but that project seems to be dead, and the maintainer has not made an update in two years.

I was able to take their PKGBUILD file and make an attempt at modifying it for use with version 17.0.335 which is supposed to properly support Wayland, but this realistically is somewhat beyond my skill. I got something which successfully builds and installs everything (or so it would seem), but the integration between Keyman and IBus somehow seems to be lacking, since the keyboards I install in Keyman do not appear as options in the IBus menus, despite restarts. Likewise, running ibus list-engine | grep keyman returns no results, seemingly indicating that ibus is not aware of Keyman’s existence.

Does anyone have any ideas as to how to remedy this situation? The PKGBUILD file I have created is provided, if anyone notices anything egregiously mistaken.

pkgname=keyman
pkgver=17.0.335
pkgrel=1
pkgdesc="IBus engine supporting over 1,000 keyboard layouts (former KMFL)"
arch=('i686' 'x86_64')
url="https://keyman.com/linux/"
license=('GPL')
depends=('ibus' 'webkit2gtk' 'python-magic' 'python-requests-cache'
    'python-numpy' 'python-pillow' 'python-qrcode' 'python-lxml' 
    'python-sentry_sdk')
makedepends=('meson' 'git' 'python-setuptools' 'perl-locale-gettext' 'help2man'
    'python-build' 'python-installer' 'python-wheel' 'nodejs' 'npm')
optdepends=(
    'keyman-onboard: on-screen keyboard'
    'hotdoc: C API documentation generation'
)
replaces=('kmflcomp' 'libkmfl' 'ibus-kmfl')
conflicts=('kmflcomp' 'libkmfl' 'ibus-kmfl')
source=("$pkgname-$pkgver.tar.gz::https://downloads.keyman.com/linux/stable/$pkgver/keyman-$pkgver.tar.gz")
sha256sums=('165a31b3c8399e74fe1ae7d223bccac619de9a34960c31d5cac876531b6527cc')

build() {
    echo -e "\n\n### build 'keyman' ######\n\n"
    cd "$srcdir/keyman/core"

    # This works only in this fashion for some reason
    pushd "$srcdir/keyman/common/tools/hextobin"
    ./build.sh configure
    ./build.sh build
    popd

    # Comment out bits that are causing a test failure
    sed -i '/# Setup kmc/,/endforeach/ s/^/#/' "$srcdir/keyman/core/tests/unit/ldml/keyboards/meson.build"
    sed -i '/^foreach kbd : tests_with_testdata/,/^endforeach/ s/^/#/' "$srcdir/keyman/core/tests/unit/ldml/keyboards/meson.build"
    sed -i '/^foreach kbd : tests_from_cldr/,/^endforeach/ s/^/#/' "$srcdir/keyman/core/tests/unit/ldml/keyboards/meson.build"
    sed -i '/^ldml = executable/,/^)/ s/^/#/' "$srcdir/keyman/core/tests/unit/ldml/meson.build"
    sed -i '/test.*ldml/ s/^/#/' "$srcdir/keyman/core/tests/unit/ldml/meson.build"

    # Set C++ flags
    export CXXFLAGS="$CXXFLAGS -O2 -std=c++17"

    # Build the core using Meson
    arch-meson ./ build \
        --prefix=/usr \
        --libexecdir=/usr/lib/ibus \
        --datadir=/usr/share

    # Compile the project
    meson compile -C build

    echo -e "\n\n### build 'keyman-config' ######\n\n"
    cd "$srcdir/keyman/linux/keyman-config"
    ./build.sh
    python -m build --wheel --no-isolation
    make man
}

check() {
    cd "$srcdir/keyman/core"
    # meson test -C build
}

package() {
    export CXXFLAGS="$CXXFLAGS -O2 -std=c++17"
    export LDFLAGS="$LDFLAGS -licuuc -licui18n"
    #suppressing errors for C because it complains about Ibus version seemingly incorrectly
    export CFLAGS="$CFLAGS -Wno-error"
    cd "$srcdir/keyman/core"
    meson install -C build --destdir "$pkgdir"

    cd "$srcdir/keyman/linux/ibus-keyman"
    DESTDIR="$pkgdir" ./build.sh install

    cd "$srcdir/keyman/linux/keyman-config"
    python -m installer --destdir="$pkgdir" dist/*.whl

    # man
    install -Dm644 --target-directory="$pkgdir/usr/share/man/man1" ../../debian/man/*.1
    install -Dm644 --target-directory="$pkgdir/usr/share/keyman/icons" keyman_config/icons/*

    # icons app
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/24x24/apps" icons/24/km-config.png
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/32x32/apps" icons/32/km-config.png
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/48x48/apps" icons/48/km-config.png
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/64x64/apps" icons/64/km-config.png
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/128x128/apps" icons/128/km-config.png

    # icons mime
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/16x16/mimetypes" icons/16/application-x-kmp.png
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/24x24/mimetypes" icons/24/application-x-kmp.png
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/32x32/mimetypes" icons/32/application-x-kmp.png
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/48x48/mimetypes" icons/48/application-x-kmp.png
    install -Dm644 --target-directory="$pkgdir/usr/share/icons/hicolor/64x64/mimetypes" icons/64/application-x-kmp.png

    # desktop
    install -Dm644 --target-directory="$pkgdir/usr/share/applications" resources/km-config.desktop 

    # mime
    install -Dm644 resources/keyman.sharedmimeinfo "$pkgdir/usr/share/mime/packages/keyman.xml"

    # glib schemas
    install -Dm644 --target-directory="$pkgdir/usr/share/glib-2.0/schemas" resources/com.keyman.gschema.xml
    
    # bash completions
    install -Dm644 --target-directory="$pkgdir/usr/share/bash-completion/completions/" *.bash-completion
    for file in $pkgdir/usr/share/bash-completion/completions/*; do
        mv -- "$file" "${file%%.bash-completion}"
    done
}

Try and change

--libexecdir=/usr/lib/ibus

to
--libexecdir=/usr/libexec
in the PKGBUILD file

(or move ibus-engine-keyman to /usr/libexec)

You might have to reboot or restart ibus (ibus restart) afterwards.

Does this make a difference?

I’ve found the problem! There was a meson.build file that kept installing the keyman.xml file to /usr/local/share/ibus/component instead of /usr/share/ibus/component. There might be a cleaner way to handle it, but a sed command to replace the offending line and feed it the correct location does the job:

    # Fix IBus keyman.xml installation location
    pushd "$srcdir/keyman/linux/ibus-keyman/src"
    sed -i "s|get_option('datadir') / 'ibus/component'|'/usr/share/ibus/component'|" meson.build
    popd

Eventually the goal would probably to call the top-level meson.build file with a --prefix=/usr and --datadir=/usr/share rather than calling the build.sh file for the ibus-keyman component, but for the time being I didn’t want to play around too much with trying to figure out if that causes other issues so we’re doing the bandaid fix.

IMPORTANTLY ibus also needs a restart after installation with ibus restart, otherwise it won’t reload the engine.

Great that you found the problem!

As a side note, you should be able to pass --prefix=/usr --datadir=/usr/share to build.sh if you call it like this:

# in Keyman root directory
./build.sh configure,build:linux -- --prefix=/usr --datadir=/usr/share

(does also work for the other build.sh scripts)