pkexec doesn't show onscreen keyboard

I have an web application that runs on a pc without a physical keyboard that is opened in chrome. I use the following command:

pkexec --user <user> google-chrome-stable --force-renderer-accessibility --app "http://my/url"

This shows the right url, but does not show me the onscreen keyboard when I select a text field. If I remove the pkexec it does show me the onscreen keyboard. What can I do to make it also work with the pkexec?

I use Debian 9.4 and the OSK is the gnome onscreen keyboard.

I noticed that when testing with gedit iso chrome, it works fine:

pkexec --user <user> gedit

Both executables have a similar policy file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>

  <action id="org.freedesktop.policykit.pkexec.run-chrome">
    <message>Authentication is required to run Chrome</message>
    <description>Run Chrome</description>
    <defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/google-chrome-stable</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
  </action>

It seems like the dbus calls to show the keyboard are no longer send when I use pkexec. If I look at the dbus-monitor the calls do come in when I run the command

google-chrome-stable --force-renderer-accessibility --app "http://my/url"

But if I add pkexec --user <user> to the command it no longer sends dbus messages like this:

method call time=1710323137.837430 sender=:1.101 -> destination=org.gnome.Caribou.Keyboard serial=2172 path=/org/gnome/Caribou/Keyboard; interface=org.gnome.Caribou.Keyboard; member=Show
Asked By: Frank

||

I found a solution. It appears that a environment variable had to be copied:

pkexec --user <user> env QT_ACCESSIBILITY=$QT_ACCESSIBILITY bash -c "google-chrome-stable --force-renderer-accessibility --app='http://my/url'"
Answered By: Frank
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.