Onboard Interacts with Mate Screensaver to Hamper Unlocking the Session

I recently had a problem with Onboard not popping up on the lock screen after resuming from suspend. As I had my convertible laptop in tablet mode at the time, with the keyboard disabled, that prevented me from entering my password. When I tried a power-cycle restart, it didn't end well:

Now that I'm up and running again on my laptop, I've gone back to investigate the original problem: Onboard sometimes isn't shown on the mate-screensaver lock screen. And I think I've identified the problem.

The Onboard Preferences dialog has a setting labeled, "Show when unlocking the screen." I have that box checked. So far, so good.

But as it turns out, you also have to (or at least on this machine, I had to) ensure two settings for mate-screensaver are correctly set before Onboard will be displayed on the lock screen:

  1. In the gsettings database, you must set org.mate.screensaver embedded-keyboard-enabled to true.
  2. In the gsettings database, you must also set org.mate.screensaver embedded-keyboard-command to an appropriate command, such as onboard -e -m".

Okay, I did both of those, and sometimes Onboard shows up on the lock screen and sometimes it doesn't.

Here's what I found to be happening:

  1. Whenever you change Onboard from being hidden (iconized) to being shown, or if it automatically pops up when a text input field receives focus, the value of org.mate.screensaver embedded-keyboard-enabled changes to true.
  2. Whenever you hide (iconize) Onboard, or if it automatically iconizes when no text input field has focus, the value of org.mate.screensaver embedded-keyboard-enabled changes to false.

Here's my proof:

This first screenshot shows Onboard visible on the screen, and gsettings reports a value of true for org.mate.screensaver embedded-keyboard-enabled.

This second screenshot is after I iconized Onboard, and now gsettings reports a value of false for org.mate.screensaver embedded-keyboard-enabled.

This third screenshot shows Onboard visible on the screen again, and gsettings once again reports a value of true for org.mate.screensaver embedded-keyboard-enabled.

I don't know whether Onboard is changing the settings of mate-screensaver, or whether mate-screensaver is watching Onboard's show/hide status and changing its settings by itself. Either way, the end result is that if Onboard is showing on the desktop when I close the laptop lid, then Onboard will appear on the lock screen when I open the laptop lid.

And conversely, if Onboard is hidden on the desktop when I close the laptop lid, then Onboard will not appear on the lock screen when I open the laptop lid.

Are Onboard and mate-screensaver supposed to be working this way? Or is something wrong with the installation of one or the other on my laptop? I doubt that, since I did a fresh install of UM 22.04 followed by an online upgrade to UM 24.04.2 just two days ago. Perhaps someone can try this on their machine and verify whether they get the same result.

3 Likes

A possible workaround is to add a service to the systemd sleep.target, this would be similar to the 'lock on suspend' workaround from: How to lock screen on suspend? - #13 by moocan. Instead of locking stuff, we use DBUS to tell Onboard to show up.

The wake-up command is here: onboard/DBUS.md at main · dr-ni/onboard · GitHub

So, roughly speaking (I haven't tested any of this) you could create a file like /etc/systemd/system/wakeup-onboard-on-suspend.service

[Unit]
Description="Wake up that Onboard keyboard before suspend"
Before=sleep.target

[Service]
Type=oneshot
User=root
ExecStartPre=/usr/bin/logger --tag 'loginctl' --priority auth.info 'Sending wakeup to Onboard keyboard'
ExecStart=dbus-send --type=method_call --print-reply --dest=org.onboard.Onboard /org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.Show
StandardOutput=journal

[Install]
WantedBy=sleep.target

Then systemd enable wakeup-onboard-on-suspend.service should do the trick to get the service going.

If you can get something like that working, then you can always expand on it to make it more user-friendly (i.e. you could write a more sophisticated script that remembers the status of Onboard prior to sleep, and restore it, etc).

2 Likes

You might need to edit the dbus-send command a little; I haven't looked at the technical details of how mate-screensaver deals with changes to onboard's status.

3 Likes

Thanks, @stephematician.

Just curious: Were you able to verify this same behavior?

My observation is that, from the command line, I can use a gsettings command to set org.mate.screensaver embedded-keyboard-enabled to true after Onboard iconizes and that key remains true until the next time Onboard's window state changes from shown to hidden. So the probability seems high (to me) that the flip in embedded-keyboard-enabledis triggered by Onboard's state change, not, for example, by any continuous monitoring of the embedded-keyboard-enabled key.

So my first attempt will be to run a simple background script that uses gsettings monitor to continuously watch for a change in the org.mate.screensaver embedded-keyboard-enabled key and immediately set it back to true whenever Onboard or mate-screensaver changes it to false.

If that doesn't work, I'll definitely resort to your suggestion to create a systemd service.

Thank you for your help, and I'll post me results either way.

2 Likes

Which version of UM and Onboard are you using? The package on noble universe, from what I can tell, is not functional - it raises a segfault after a short period of time. That said; I was able to have it appear on the lock screen for a short period of time (prior to segfault) just by setting the org.mate.screensaver keys required (and selecting 'Appear on lock screen' within Onboard's settings).

1 Like

I gather, then, that the segfault prevented you from verifying that iconizing Onboard changes the embedded-keyboard-enabled setting?

My system specs:

OS: Ubuntu MATE 24.04.2 LTS x86_64
Host: 82G4 IdeaPad Flex 3 11ADA05
Kernel: 6.8.0-63-generic
Shell: bash 5.2.21
DE: MATE 1.26.1
WM: Metacity (Marco)
Theme: YaruOk [GTK2/3]
Icons: mate [GTK2/3]
CPU: AMD Athlon Silver 3050e with Radeon Graphics (4) @ 1.400GHz
GPU: AMD ATI Radeon Vega Series / Radeon Vega Mobile Series
Memory: 1621MiB / 3299MiB

My version of Onboard is 1.4.1-5ubuntu6, which is from noble/universe amd64 Packages.

The segfault you experienced isn't too surprising. My impression is that Onboard has a history of being sensitive to system configuration and its own settings, but generally works well if you can get it configured compatibly.

BTW: When UM decides to switch to Wayland, Onboard will probably become obsolete. A possible replacement might be squeekboard:

2 Likes

I looked into it more (I was being lazy before), it's relatively easy to prevent the segfault by switching from Xinput to GTK backend.

Having done that; the onboard keyboard works for me. When it's sitting in the tray (not on screen); the org.mate.screensaver.embedded-keyboard-enabled stays true. I can close the onboard keyboard, the setting is still true. It appears on the unlock screen.

So, perhaps this is a settings issue; or perhaps some other software is modifying the mate screensaver gsettings.

2 Likes

The "Show when unlocking the screen" setting does nothing on MATE (unless you use gnome screensaver) as it updates the schema org.gnome.desktop.screensaver which is not used by MATE screensaver.

2 Likes

Yes, I was aware that the "Show when unlocking the screen" option has no effect under Ubuntu MATE, but I didn't know why, so thank you for that information.

I switched the "Input event source" to "GTK" quite some time ago. It was never stable when set to "XInput". Your info about the segfault explains that, so thank you again.

My latest experiment indicates quite strongly that this is not a fluke with my laptop, and I don't think any other software other than onboard and mate-screensaver is involved, although I can't prove that definitively. But the evidence is strong.

Here's my experiment. I opened a terminal window and ran the command:

gsettings monitor org.mate.screensaver embedded-keyboard-enabled

This command runs continuously until you kill it with Ctrl+C. It prints a line to STDOUT whenever the value of the specified key changes.

With that command running, I toggled onboard between shown and hidden using three different techniques. And every time, toggling the visibility of onboard toggled the value of embedded-keyboard-enabled:

  1. I toggled onboard by clicking the icon in the tray. This toggled the value of embedded-keyboard-enabled.
  2. I enabled the "Show floating icon when Onboard is hidden" option in Onboard preferences, and then toggled onboard by clicking the floating icon (to show onboard) and clicking the "x" key in the upper right corner of the keyboard (to hide onboard). Both actions toggled the value of embedded-keyboard-enabled.
  3. I enabled the "Auto-show when editing text" option in Onboard Preferences, and then triggered onboard to alternately auto-show and auto-hide by clicking in the terminal window to give it focus, and then clicking on the desktop to take focus away. Both actions toggled the value of embedded-keyboard-enabled as Onboard popped up and then iconized.

I ran this experiment both on my Lenovo laptop and on my Intel NUC desktop computer and saw the same results. Both systems are running UM 24.04.2 and Onboard 1.4.1-5. When Onboard pops up, the value of embedded-keyboard-enabled toggles true. When Onboard iconizes, the value of embedded-keyboard-enabled toggles false. If I lock or suspend either computer when Onboard is iconized, then Onboard does not appear on the lock screen.

I devised a script that solves the problem. It's crude, but effective. I checked it using mate-system-monitor, and the script uses no CPU cycles while waiting for the key to change:

#!/bin/bash
gsettings monitor org.mate.screensaver embedded-keyboard-enabled |  \
while read -r line ; do
  gsettings set org.mate.screensaver embedded-keyboard-enabled true
done
1 Like

Interesting, tried your example on my laptop; no changes in the key. I'm using onboard 1.4.1-5ubuntu6 package, and inxi -Sz shows:

System:
  Kernel: 6.8.0-63-generic arch: x86_64 bits: 64
  Desktop: MATE v: 1.26.2 Distro: Ubuntu MATE 24.04.2 LTS (Noble Numbat)

Looks same to me! How odd.

Even more odd is that, looking at the source code of mate-screensaver, it simply monitors the key and reads the value into an internal preferences structure (see mate-screensaver/src/gs-prefs.c at e3f66072bcf78463bffe1bef56e2586ebf2f6437 · mate-desktop/mate-screensaver · GitHub). I can't find any references in the source code that suggest it tries to set the key.

onboard (source) doesn't seem to be interested in the org.mate.screensaver schema at all - so I can't pinpoint where the settings change is coming from on your machine (probably ... neither of those applications? maybe something like mate-settings-daemon but I have no idea what that does).

Anyway - very nice workaround! Wish I could help more but I'm stumped. Might be best to log a bug upstream with mate-screensaver and onboard if you want this fixed (eventually).