Schneegans / gnome-shell-pod

:package: A Podman container which runs GNOME Shell in xvfb
MIT License
49 stars 12 forks source link

Unable to get gdbus call to an extension in a GNOME pod #10

Open kortschak opened 6 months ago

kortschak commented 6 months ago

I am working on getting CI testing built for an application that interacts with a GNOME extension. I'm trying to use gnome-shell-pod to help with this.

To start with I want to demonstrate that I can get a gdbus call to the extension to work after it's been installed and enabled, but I am unable to do this.

With this script

# Run the container in detached mode.
POD=$(podman run --rm --cap-add=SYS_NICE --cap-add=IPC_LOCK -td ghcr.io/schneegans/gnome-shell-pod-38)

do_in_pod() {
  podman exec --user gnomeshell --workdir /home/gnomeshell "${POD}" set-env.sh "$@"
}

pushd dex/cmd/watcher/extensions/user-activity@kortschak.io
gnome-extensions pack --force
podman cp user-activity@kortschak.io.shell-extension.zip ${POD}:/home/gnomeshell
do_in_pod gnome-extensions install --force user-activity@kortschak.io.shell-extension.zip
rm user-activity@kortschak.io.shell-extension.zip
popd

# This is necessary otherwise wait-user-bus.sh gives
# "Failed to get credentials: No data available"
sleep 5

# Wait until the user bus is available.
do_in_pod wait-user-bus.sh

# Start GNOME Shell.
do_in_pod systemctl --user start "gnome-xsession@:99"

# Wait some time until GNOME Shell has been started.
sleep 5

do_in_pod gnome-extensions list
do_in_pod gnome-extensions enable user-activity@kortschak.io
do_in_pod gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell/Extensions/UserActivity --method org.gnome.Shell.Extensions.UserActivity.Details

# Now we can stop the container again.
podman stop ${POD}

I get this output.

~/dex/cmd/watcher/extensions/user-activity@kortschak.io ~
~
user-activity@kortschak.io
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path ?/org/gnome/Shell/Extensions/UserActivity?

I see the extension is present in the list, but it is not found by the gdbus call.

On the non-pod host (a 23.10 VM) I see the following:

$ gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell/Extensions/UserActivity --method org.gnome.Shell.Extensions.UserActivity.Details
('{"wid":1917105287,"name":"gnome-terminal-server","class":"gnome-terminal-server","window":"user@mantic: ~","last_input":"2024-04-06T08:11:39.741Z","pid":3404,"layer":2}',)

So I am clearly missing something out. What is it that I am missing?

Schneegans commented 6 months ago

Hi there! My first guess would be that a little sleep could help after do_in_pod gnome-extensions enable user-activity@kortschak.io. This is most likely an asynchronous operation and it may take some time until the interface is available....

Does this help?

kortschak commented 6 months ago

Unfortunately not; even with a 60 second wait. This reflects the behaviour I saw when I was doing the same thing interactively where I never was able to get the interface to come up.