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

feat(linux): Start dbus if not running #10863

Merged
merged 11 commits into from Mar 26, 2024
Merged

Conversation

ermshiperete
Copy link
Contributor

@ermshiperete ermshiperete commented Feb 27, 2024

This change checks the DBus environment variables when initializing the keyman_config module and starts DBus if the variables are not set. This particularly happens when trying to install or uninstall a keyboard for a different user, which will now be possible with this change.

Fixes #9363.

User Testing

Preparations

  • The tests should be run on these Linux platforms:

    • GROUP_FOCAL: Ubuntu 20.04 Focal with Gnome Shell and X11
    • GROUP_JAMMY_WAYLAND: Ubuntu 22.04 Jammy with Gnome Shell and Wayland
  • Install build artifacts of this PR

  • Reboot

  • Create a second user myuser without admin privileges

Tests

TEST_INST: Can install a keyboard for the second user

  • in a terminal window, login as myuser by running su --login myuser
  • as myuser run: km-package-install -p sil_euro_latin --bcp47 de
  • verify that this doesn't output errors
  • logout and login as myuser
  • verify that the "German (EuroLatin (SIL))" keyboard appears in the toolbar
  • verify that you can switch to and type with that keyboard

TEST_UNINST: Can uninstall a keyboard for the second user

  • logout and login as regular user again
  • in a terminal window, login as myuser by running su --login myuser
  • as myuser run: km-package-uninstall sil_euro_latin
  • verify that this doesn't output errors
  • logout and login as myuser
  • verify that the "German (EuroLatin (SIL))" keyboard no longer appears in the toolbar

This change checks the DBus environment variables when initializing the
`keyman_config` module and starts DBus if the variables are not set.
This particularly happens when trying to install or uninstall a keyboard
for a different user, which will now be possible with this change.

Fixes #9363.
@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed labels Feb 27, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Feb 27, 2024

User Test Results

Test specification and instructions

  • ✅ GROUP_FOCAL: Ubuntu 20.04 Focal with Gnome Shell and X11

    2 tests PASSED
    • TEST_INST (PASSED): Retested this PR, as per Eberhard's suggestion with the attached PR build (Keyman 17.0.293-beta (package version 17.0.293-1~PR-10863-2581.1+focal1) on Ubuntu 20.04 Focal Linux (X11) and here is my observation : 1. In the terminal window, logged in to myuser. 2. In myuser, run the above-mentioned command line to install sil_euro_latin keyboard. It shows some irrelevant error message on the terminal window. 3. Logged out and logged in as myuser. Verfied that the "German (EuroLatin (SIL))" keyboard appeared in the toolbar. Able to type in that keyboard in the text editor. (notes)
    • TEST_UNINST (PASSED): 1. Logged out and logged in as regular user again. 2. In terminal window, logged in as myuser. 3. As myuser, run the above mentioned command. It shows up some irrelevant error message on the terminal window. 4. Logged out and logged in as myuser. Verified that the "German (EuroLatin (SIL))" keyboard did not appear in the toolbar.
  • ✅ GROUP_JAMMY_WAYLAND: Ubuntu 22.04 Jammy with Gnome Shell and Wayland

    2 tests PASSED
    • TEST_INST (PASSED): Retested (as per Eberhard's suggestion) with the attached PR build (Keyman 17.0.293-beta (package vesion 17.0.293-1~PR-10863-2581.1+jammy1) on Ubuntu 20.04 Focal Linux (Wayland) and here is my observation : 1. In the terminal window, logged in to myuser. 2. In myuser, run the above mentioned command line to install sil_euro_latin keyboard. It shows up some irrelevant error message on the terminal window. 3. Logged out and logged in as myuser. Verfied that the "German (EuroLatin (SIL))" keyboard appeared in the toolbar. Able to type in that keyboard in the text editor. (notes)
    • TEST_UNINST (PASSED): 1. Logged out and logged in as regular user again. 2. In a terminal window, logged in as myuser. 3. As myuser, run the above mentioned command . It shows up some irrelevant error message on the terminal window. 4. Logged out and logged in as myuser. Verified that the "German (EuroLatin (SIL))" keyboard did not appear in the toolbar.

Test Artifacts

logging.warning('Got unexpected line from dbus-launch: %s', line)
continue
name = line[:equal_sign]
value = line[equal_sign+1:]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this empty if = is at the end of the line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@ermshiperete ermshiperete marked this pull request as draft February 29, 2024 16:16
@ermshiperete
Copy link
Contributor Author

When installing the packages for this PR on Focal it's no longer possible to type with Keyman. Most often the keyboards don't show up, and if they do typing doesn't work.

@ermshiperete
Copy link
Contributor Author

Things work after rebooting after the installation.

@ermshiperete ermshiperete marked this pull request as ready for review February 29, 2024 17:49
@bharanidharanj
Copy link

Test Results

GROUP_FOCAL: Ubuntu 20.04 Focal with Gnome Shell and X11

  • TEST_INST (FAILED): Tested with the attached PR build on Ubuntu 20.04 Focal Linux OS (x11) (VM) and here is my observation: 1. Installed the PR build Keyman 17.0.279-beta (package version 17.0.279-1~PR-10863-2470.1+focal1). 2. Restarted the system. 3. Created a second user 'myuser1' without admin privileges. 4. Opened terminal window. Changed to second user 'myuser1'. 5. Ran the above-mentioned command and noticed that it is displaying an error message.

  • TEST_UNINST (FAILED): Tested with the attached PR build on Ubuntu 20.04 Focal Linux OS (x11) (VM) and here is my observation: 1. Restarted the system. 2. Opened terminal window. Changed to second user 'myuser1'. 5. Ran the above-mentioned (uninstall) command and noticed that it is displaying an error message.

@mcdurdin mcdurdin modified the milestones: B17S2, B17S3 Mar 3, 2024
@bharanidharanj
Copy link

Test Results

GROUP_JAMMY_WAYLAND: Ubuntu 22.04 Jammy with Gnome Shell and Wayland

  • TEST_INST (PASSED): Tested with the attached PR build (keyman 17.0.279-beta (package version 17.0.279-1~PR-10863-2470.1+jammy1) on Ubuntu 22.04 Jammy with Gnome Shell and Wayland (Virtual Box) and here is my observation: 1. Created a second user 'myuser' without admin privileges. 2. Changed to second user 'myuser'. 3. Run the above mentioned package-install command on the terminal. 4. Verified it doesn't output any errors. 5. logged out then logged in as 'myuser'. 5. Verified that the "German (EuroLatin(SIL))" keyboard is appearing in the toolbar. 6. Verified that switching to German Keyboard and typing with that keyboard is possible.

@bharanidharanj
Copy link

Test Results

GROUP_JAMMY_WAYLAND: Ubuntu 22.04 Jammy with Gnome Shell and Wayland

  • TEST_UNINST (PASSED): 1. Logged in as a regular user again. 2. Changed to Second user 'myuser' in the terminal window. 3. Run the above mentioned package-uninstall command and verified that it doesn't output any errors. 4. Logged out then logged in as 'myuser'. Verified that the "German (EuroLatin(SIL))" keyboard doesn't appear in the toolbar. Seems to be working as expected.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Mar 4, 2024
@darcywong00 darcywong00 modified the milestones: B17S3, B17S4 Mar 16, 2024
If we want to log messages we need to start DBus after we initialized
logging.
@ermshiperete
Copy link
Contributor Author

GROUP_FOCAL:

  • TEST_INST (SKIPPED): error message is unrelated
  • TEST_UNINST (SKIPPED): error message is unrelated

Also need to start as daemon so that it works when run as a different user.
@ermshiperete ermshiperete marked this pull request as draft March 21, 2024 21:31
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.
`DBUS_SESSION_BUS_PID` gets only set when launching dbus in the process,
but not when it's already running.
@ermshiperete ermshiperete marked this pull request as ready for review March 22, 2024 16:07
@ermshiperete
Copy link
Contributor Author

@bharanidharanj Could you please run the tests again? I had to change quite a bit. Thanks! Note that on Ubuntu 20.04 Focal you can ignore the "Unable to init server: Could not connect: Connection refused" message.

@keymanapp-test-bot retest

@keymanapp-test-bot keymanapp-test-bot bot added the user-test-required User tests have not been completed label Mar 22, 2024
@bharanidharanj
Copy link

Test Results

GROUP_FOCAL: Ubuntu 20.04 Focal with Gnome Shell and X11

  • TEST_INST (PASSED): Retested this PR, as per Eberhard's suggestion with the attached PR build (Keyman 17.0.293-beta (package version 17.0.293-1~PR-10863-2581.1+focal1) on Ubuntu 20.04 Focal Linux (X11) and here is my observation : 1. In the terminal window, logged in to myuser. 2. In myuser, run the above-mentioned command line to install sil_euro_latin keyboard. It shows some irrelevant error message on the terminal window. 3. Logged out and logged in as myuser. Verfied that the "German (EuroLatin (SIL))" keyboard appeared in the toolbar. Able to type in that keyboard in the text editor.

  • TEST_UNINST (PASSED): 1. Logged out and logged in as regular user again. 2. In terminal window, logged in as myuser. 3. As myuser, run the above mentioned command. It shows up some irrelevant error message on the terminal window. 4. Logged out and logged in as myuser. Verified that the "German (EuroLatin (SIL))" keyboard did not appear in the toolbar.

@bharanidharanj
Copy link

Test Results

GROUP_JAMMY_WAYLAND: Ubuntu 22.04 Jammy with Gnome Shell and Wayland

  • TEST_INST (PASSED): Retested (as per Eberhard's suggestion) with the attached PR build (Keyman 17.0.293-beta (package vesion 17.0.293-1~PR-10863-2581.1+jammy1) on Ubuntu 20.04 Focal Linux (Wayland) and here is my observation : 1. In the terminal window, logged in to myuser. 2. In myuser, run the above mentioned command line to install sil_euro_latin keyboard. It shows up some irrelevant error message on the terminal window. 3. Logged out and logged in as myuser. Verfied that the "German (EuroLatin (SIL))" keyboard appeared in the toolbar. Able to type in that keyboard in the text editor.

  • TEST_UNINST (PASSED): 1. Logged out and logged in as regular user again. 2. In a terminal window, logged in as myuser. 3. As myuser, run the above mentioned command . It shows up some irrelevant error message on the terminal window. 4. Logged out and logged in as myuser. Verified that the "German (EuroLatin (SIL))" keyboard did not appear in the toolbar.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Mar 25, 2024
@ermshiperete ermshiperete merged commit 58ce4fb into beta Mar 26, 2024
7 checks passed
@ermshiperete ermshiperete deleted the feat/linux/9363DBusEnv branch March 26, 2024 14:56
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.295-beta

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

Successfully merging this pull request may close these issues.

feat(linux): Allow to install/uninstall keyboards if DBus is not started
5 participants