Commit graph

56 commits

Author SHA1 Message Date
Eberhard Beilharz
76866b275b
feat(linux): address code review comments
- add date to header and filename
- add state of ibus
- add privacy statement and link to privacy policy
2026-02-26 17:04:49 +01:00
Eberhard Beilharz
cb1de97ae7
feat(linux): implement diagnostic report
This change allows to collect data for a diagnostic report. This can be
done either from the command line through the new `km-diag-report` tool,
or in `km-config` from the new `Support` tab that allows to generate the
report and then copy it to the clipboard or save as a file.

The diagnostic report contains installed browsers and their versions and
installation methods as well as the default browser. It checks for
browsers installed through apt (Ubuntu/Debian), snap, and flatpak.

The change also has an implementation for pacman (Arch Linux) and
dnf/yum (Fedora), although these have not been tested.

Fixes: #7784
2026-02-13 17:29:22 +01:00
Eberhard Beilharz
c6e7337475
refactor(linux): make get_ibus_version() public 2026-02-12 16:49:32 +01:00
Eberhard Beilharz
b7d5e89577
fix(linux): fix installing keyboard in shared area
Installing into the shared area (`/usr/local/share`) requires `root`
permissions, so in order to install into the shared area the user has
to call `km-package-install` with `sudo`. But we also want to add the
keyboard to the user's list of available keyboards so that he can
switch to it. That needs to be done in the user context. However,
when `sudo` ran the command in the user context, the environment
variables to connect to the user's session dbus were not set.

This change fixes this by passing `DBUS_SESSION_BUS_ADDRESS` along
with the `sudo -u <user>` call. Since `root` doesn't have this variable
set (or at least not pointing to the user's dbus), we construct the
dbus address based on the user's uid.

On newer Ubuntu versions (>=25.04) we also have to set `XDG_RUNTIME_DIR`,
at least when running the autopkgtests.

Fixes: #14911
2025-10-14 17:54:36 +02:00
Eberhard Beilharz
8d9c3ee09b
fix(linux): don't crash on invalid languages in keyboard
Fixes: #14748
Fixes: KEYMAN-LINUX-8Q
2025-09-15 16:37:22 +02:00
Eberhard Beilharz
189ee50e24
fix(linux): don't crash if kmp.json is missing keyboards section
Some keyboards seem to be missing the `keyboards` section in the
`kmp.json` file. This change prevents a crash and instead returns `None`
and thus we don't create a .ldml file and so onboard will show the
default keyboard instead. The alternative would be to create an empty
.ldml file, but that causes onboard to show a keyboard with all key caps
being empty.

Fixes: #14707
Fixes: KEYMAN-LINUX-8P
Test-bot: skip
2025-09-08 18:06:36 +02:00
Eberhard Beilharz
951793ea84
fix(linux): normalize language tags from keyboard
This fixes a bug where a keyboard didn't show up in the language dropdown
if the first language it specified wasn't a normalized language tag.
Previously in that case we added a custom keyboard with whatever language
tag the keyboard specified. With this change we now continue to use
the first language of the first keyboard but normalize it. Since the
selection of the language now happens a little earlier it is slightly
possible that there will be unexpected side effects that didn't show up
in my testing.

Fixes: #14465
2025-08-18 19:49:38 +02:00
Eberhard Beilharz
2ff9e309fa
chore(common): allow to run tests in virtual environment
This changes the shebang at the top of the file to allow use Python
from a virtual environment instead of hard-coding the path. This might
not be strictly necessary, but reduces confusion and doesn't hurt.
2025-04-29 19:20:49 +02:00
Marc Durdin
f7bed1d2f6 chore(common): update tests where region data has been added
The 2025-02-18 release of langtags.json includes tag data for sa-Latn
and he-Latn, so tests related to those tags now need to account for
region.

Fixes: #13288
2025-03-10 09:33:01 +07:00
Eberhard Beilharz
6fe916ca8b
fix(linux): ignore DBusException during install and uninstall
Fixes: #12902
Fixes: #13283
Fixes: KEYMAN-LINUX-7J
Fixes: KEYMAN-LINUX-7R
2025-02-26 18:24:27 +01:00
Eberhard Beilharz
615d90765c
refactor(linux): extract method for setting up mocks in tests 2025-02-26 12:01:54 +01:00
Eberhard Beilharz
4a852c9522
chore(linux): rename test files
This change rename the test files for Linux according to the discussion
at the Keyman conference in November 2024.

Python is pretty opinionated about the naming of files, so we have to
use `*_tests.py` as test filename instead of the usual `*.tests.py`.
2024-11-26 19:06:02 +01:00
Eberhard Beilharz
50228a8266
fix(linux): properly deal with types of names
Names can be Unicode strings or byte arrays. This change allows for both
kinds. Also properly deal with the case when we can't get the name from
the .ttf file. And finally change the test so that we don't need the
`KbdKhmr.ttf` font.
2024-08-24 12:16:04 +08:00
Eberhard Beilharz
c8cbc2fefe
fix(linux): get font facename from .ttf file 2024-08-24 11:31:23 +08:00
Eberhard Beilharz
c99e833c8e
fix(linux): Add font name without file extension 2024-08-24 10:25:57 +08:00
Eberhard Beilharz
16ce5b0408
fix(linux): get oskFont from kmp.json instead of UnicodeFont 2024-08-24 10:07:36 +08:00
Eberhard Beilharz
a22a40fe2e
fix(linux): add keymanFacename to .ldml file
This change adds the `keymanFacename` attribute based on UnicodeFont
or AnsiFont to the root element of the generated .ldml file so that
onboard-keyman can display the proper font for the osk.

Fixes: #12019
2024-08-23 22:42:16 +02:00
Eberhard Beilharz
7478db8b57
chore(linux): Fix typo
This suddenly started failing. I guess there was a deprecated
`assertEquals` in older Python libraries, but with the latest version in
Ubuntu 24.04 Noble this disappeared. Anyway, with this change we use
the same assert method as in the other test files.
2024-05-03 17:39:14 +02:00
Eberhard Beilharz
2044b188f8
fix(linux): Improve detection of Gnome environment
This change improves the way we detect if we're running a Gnome based
UI that needs it's keyboards installed under
`org.gnome.desktop.input-sources`. We use the environment variable
`XDG_CURRENT_DESKTOP` and check if it contains the word `gnome`.
Additionally this change renames `is_gnome_shell()` to
`is_gnome_desktop()`.

Fixes #11225.
2024-04-23 15:16:03 +02:00
Eberhard Beilharz
23a558d88e
feat(linux): Deal with temporary dbus session
When we launch dbus if it is not running, we're probably (un-)installing
keyboards for a different user. This is an unusual environment where not
everything is available, e.g. dconf-service won't be running and can't
be started because DISPLAY variable is not set. This means we can't
write gsettings values through the API. However, we can read them, and we
can write a keyfile and update the database. This is what this change
implements for the cases where we started dbus.
2024-03-22 12:54:50 +01:00
Eberhard Beilharz
d396a397e3
chore(linux): Use ibus start if available
IBus around version 1.5.28 introduced the `start` subcommand for `ibus`.
If available we use that because that starts `ibus-daemon` with the
correct arguments. If the available IBus version is too old we use
our previous code where we pass arguments to `ibus-daemon` which might
be different from how ibus gets started on that system otherwise.
2024-02-26 16:34:46 +01:00
Eberhard Beilharz
4bad36089f
fix(linux): Use temp dir if we can't create cache dir
If we can't create the cache dir, e.g. if `~/.cache` doesn't exist or
if we don't have enough permissions, we now return a temporary directory.

Fixes #10033.
2024-02-09 18:01:40 +01:00
Eberhard Beilharz
91e731a955
Merge pull request #9756 from keymanapp/feat/linux/8598_kmconfig
feat(linux): Allow installing keyboards with arbitrary language 🏘️
2023-10-17 18:02:19 +02:00
Eberhard Beilharz
c56b8a72eb
chore(linux): rename parameters
This addresses code review comments.
2023-10-16 09:12:28 +02:00
Eberhard Beilharz
23cc98a690
feat(linux): Allow installing keyboards with arbitrary language 🏘️
- during installation add to the list of custom keyboards if necessary
- during uninstallation remove from the list of custom keyboards
- if list of custom keyboards has invalid values, remove those before
  saving the list

Closes #8598.
2023-10-13 16:57:57 +02:00
Eberhard Beilharz
303e57ba68
refactor(linux): Refactor mocks in ibus-util tests 2023-10-12 18:45:12 +02:00
Eberhard Beilharz
d92808e779
chore(linux): Speed up ibus-util tests 2023-10-12 18:34:50 +02:00
Eberhard Beilharz
152d36a654
fix(linux): Fix installation of keyboards with lang tag mul
We now use the canonical tag without appending the script (unless
necessary).

Fixes #8620.
2023-07-19 12:01:52 +02:00
Eberhard Beilharz
e1dc9574c3
Merge pull request #9215 from keymanapp/chore/linux/newtests
chore(linux): Add unit tests for dconf_util.py
2023-07-13 12:31:26 +02:00
Eberhard Beilharz
8b9f3eb2c5
chore(linux): Add another test 2023-07-11 17:33:46 +02:00
Eberhard Beilharz
847556b176
Merge pull request #9193 from keymanapp/chore/update-data
chore: Update standards data
2023-07-11 08:59:25 +02:00
Eberhard Beilharz
74643d39ed
chore(linux): Add unit tests for dconf_util.py
Tests were generated by ChatGPT (although it didn't get it quite
right - was missing the parameter in `self.settings.reset`).
2023-07-07 18:29:31 +02:00
Eberhard Beilharz
0f8fe48167
fix(linux): Fix Linux build
New langtags.json adds data that a test on Linux uses, so this
change adjust the test.
2023-07-06 19:47:46 +02:00
Eberhard Beilharz
9f5ac8eb4a
fix(linux): Fix uninstalling keyboard for multiple languages with ibus
After this change uninstalling a keyboard will remove all installed
language/keyboard combinations for that particular keyboard.
Previously we only uninstalled for the first language listed in the
keyboard.
2023-07-05 11:57:23 +02:00
Eberhard Beilharz
c6f4541c83
feat(linux): Fix unit tests 2023-05-30 17:51:25 +02:00
Eberhard Beilharz
2fea609714
Merge pull request #8011 from keymanapp/feat/linux/uninstall-if-error
feat(linux): Improve uninstallation
2023-01-25 16:46:56 +01:00
Kevin Schluensen
4c0ede6c4d Change tests to fit install_kmp function 2023-01-20 08:58:14 +01:00
Eberhard Beilharz
efd5200050
chore(linux): More refactoring of uninstall
This change refactors and cleans uninstall:

- rename methods to make it clear which ones are private/protected
- extract common code
- improve error reporting
2023-01-19 18:06:56 +01:00
Eberhard Beilharz
89a253b1ca
feat(linux): Enhance tab completion in km-package-install
This change adds tab completion for the bcp-47 parameter in
km-package-install.

Fixes #5361
2023-01-11 12:28:12 +01:00
Eberhard Beilharz
b1d201a3d7
feat(linux): Replace deprecated distutils
Fixes #6955
2022-08-08 16:38:35 +02:00
Eberhard Beilharz
4c1f6e7be2
fix(linux): Refactor and fix tests
- patch `is_fcitx_running()` so that tests will work without X11
- move common test code to methods
- move some tests to subtests
2022-04-12 12:09:55 +02:00
Eberhard Beilharz
ad2a6b713f
fix(linux): test fileVersion during package install
Fixes #6256
2022-04-11 18:22:46 +02:00
Eberhard Beilharz
c42a623f38
fix(linux): Don't crash when installing keyboards in Wasta
Fixes #6158. This bug got introduced in #6015.
2022-01-27 17:22:02 +01:00
Eberhard Beilharz
2ec64ac521 fix(linux): Fix unit tests 2021-12-09 14:44:33 +01:00
Eberhard Beilharz
a98300f769
fix(linux): Fix failing tests 2021-08-16 11:56:05 +02:00
Eberhard Beilharz
c35e5ff9cc
refactor(linux): Refactor install_kmp.py
- Introduce `InstallKmp` class
- Remove unused `list_files` method
- Extract common method that `install_kmp_shared` and
  `install_kmp_user` use
- Make internal methods protected
2021-05-17 10:58:04 +02:00
Eberhard Beilharz
88e83e191e
fix(linux): Address code review comment
Also add additional test cases from Windows implementation.
2021-02-09 15:51:31 +01:00
Eberhard Beilharz
42f3f36013
fix(linux): improve BCP 47 canonicalization
This is based on #4425. Also a few additional bug fixes that showed
up on the way.
2021-02-08 17:50:05 +01:00
Eberhard Beilharz
693f13a953
fix(linux): Improve fix for #3399
This improves the implementation for normalizing language tags
when installing a keyboard. Based on the Windows implementation
in `Keyman.System.CanonicalLanguageCodeUtils.pas`.

One difference to the Windows implementation is that the mapping of
3- to 2-letter tags is based on `langtags.json` instead of
`iso639-3.tab`.

Closes #3399.
2021-02-03 19:08:03 +01:00
Eberhard Beilharz
9047103028
fix(linux): Lookup language tag from keyboard
When installing a keyboard with a bcp47 tag we now look up the
language tag in the keyboard kmp.json file. This fixes #3399 in
case a script subtag is required for the language and will cause
the keyboard to properly show up in the Linux keyboard selection
list.
2020-07-24 17:54:10 +02:00