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

dbus interface for control channel #904

Closed
totaam opened this issue Jul 1, 2015 · 21 comments
Closed

dbus interface for control channel #904

totaam opened this issue Jul 1, 2015 · 21 comments

Comments

@totaam
Copy link
Collaborator

totaam commented Jul 1, 2015

Issue migrated from trac ticket # 904

component: server | priority: minor | resolution: fixed

2015-07-01 09:29:31: antoine created the issue


Some of the server's features could be exposed via dbus, this would complement the "xpra control" interface.
r9773 + r9774 already moved the dbus bits to their own module.

The service name should contain the display number to ensure it is unique, which also makes it less discoverable...

Some good pointers:

@totaam
Copy link
Collaborator Author

totaam commented Jul 8, 2015

2015-07-08 14:09:10: antoine changed status from new to assigned

@totaam
Copy link
Collaborator Author

totaam commented Jul 8, 2015

2015-07-08 14:09:10: antoine edited the issue description

@totaam
Copy link
Collaborator Author

totaam commented Sep 19, 2015

@totaam
Copy link
Collaborator Author

totaam commented Oct 4, 2015

2015-10-04 13:18:50: antoine commented


Stub with 4 methods added in r10734.

@totaam
Copy link
Collaborator Author

totaam commented Oct 5, 2015

2015-10-05 07:58:57: antoine changed status from assigned to new

@totaam
Copy link
Collaborator Author

totaam commented Oct 5, 2015

2015-10-05 07:58:57: antoine changed owner from antoine to afarr

@totaam
Copy link
Collaborator Author

totaam commented Oct 5, 2015

2015-10-05 07:58:57: antoine commented


More improvements in r10735, r10736 and r10738.
Note the namespace is changed in r10738 from /org/xpra/ServerNNN to /org/xpra/Server/NNN. (also edited as per comment:6 to match the service name change)

This could / should eventually replace the "xpra control" interface.

You can see the services using tools like d-feet:
[[Image(xpra-dbus-server-shown-with-dfeet.png)]]

And you can query things using qdbus:

$ qdbus --session org.xpra.Server13
/
/org
/org/xpra
/org/xpra/Server
/org/xpra/Client1

Finds the server started on display 13 and one client connected, then we can list all the methods:

$ qdbus --session org.xpra.Server13 /org/xpra/Server
method QString org.freedesktop.DBus.Introspectable.Introspect()
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString property_name)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QDBusVariant interface_name)
signal void org.freedesktop.DBus.Properties.PropertiesChanged(QString interface_name, QVariantMap changed_properties, QStringList invalidated_properties)
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant new_value)
method void org.xpra.Server.DisableDebug(QString category)
method void org.xpra.Server.EnableDebug(QString category)
method void org.xpra.Server.Focus(int wid)
method void org.xpra.Server.KeyPress(QString keycode)
method void org.xpra.Server.KeyRelease(QString keycode)
method QDBusVariant org.xpra.Server.ListWindows()
method void org.xpra.Server.MoveWindowToWorkspace(int wid, int workspace)
method void org.xpra.Server.RefreshAllWindows()
method void org.xpra.Server.RefreshWindow(int wid)
method void org.xpra.Server.RefreshWindows(QDBusRawType::ai window_ids)
method void org.xpra.Server.Resume()
method void org.xpra.Server.SetWindowEncoding(int wid, QString encoding)
method void org.xpra.Server.SetWindowScaling(int wid, QString scaling)
method void org.xpra.Server.SetWindowScalingControl(int wid, int scaling_control)
method void org.xpra.Server.Start(QString command)
method void org.xpra.Server.StartChild(QString command)
method void org.xpra.Server.Suspend()
method void org.xpra.Server.Ungrab()

With dbus-send, it's a bit too verbose but here it is:

$ dbus-send --session --print-reply --type=method_call --dest='org.xpra.Server13' '/org/xpra/Server' org.xpra.Server.ListWindows
method return sender=:1.551 -> dest=:1.562 reply_serial=2
   variant       array [
         dict entry(
            int32 2
            string "antoine@desktop:~/projects/Xpra/trunk/src"
         )
      ]

Sending a refresh all:

  • with dbus-send:
dbus-send --session --type=method_call \
    --dest='org.xpra.Server13' '/org/xpra/Server' \
    org.xpra.Server.RefreshAllWindows
  • with qdbus:
qdbus --session org.xpra.Server13 /org/xpra/Server \
    org.xpra.Server.RefreshAllWindows

@afarr: this is mostly a FYI, unless you can find problems with it or suggest improvements, please close.

@totaam
Copy link
Collaborator Author

totaam commented Oct 30, 2015

2015-10-30 23:59:27: afarr changed status from new to closed

@totaam
Copy link
Collaborator Author

totaam commented Oct 30, 2015

2015-10-30 23:59:27: afarr set resolution to fixed

@totaam
Copy link
Collaborator Author

totaam commented Oct 30, 2015

2015-10-30 23:59:27: afarr commented


Trying to run just for more of a sense, it looks like there's some details required to set up the dbus server, or at least name it 'org.xpra.Server' (or whatever) which isn't set up as a default.

I assume these will be configured/used later on.

Running qdbus --session org.xpra.Server /org/xpra/Server/13 from an ssh connection into a vm running a server, I get the response:

Could not connect to D-Bus server: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

When I try the same command from an xterm within the session, I just get the message Service 'org.xpra.Server' does not exist.

I suppose I'll need to learn more about using dbus...

In the meantime, I'll close this.

@totaam
Copy link
Collaborator Author

totaam commented Oct 31, 2015

2015-10-31 06:28:22: antoine uploaded file xpra-dbus-server-shown-with-dfeet.png (250.5 KiB)

d-feet shows our new dbus server - updated picture with new namespace
xpra-dbus-server-shown-with-dfeet.png

@totaam
Copy link
Collaborator Author

totaam commented Oct 31, 2015

2015-10-31 06:32:01: antoine changed status from closed to reopened

@totaam
Copy link
Collaborator Author

totaam commented Oct 31, 2015

2015-10-31 06:32:01: antoine removed resolution (was fixed)

@totaam
Copy link
Collaborator Author

totaam commented Oct 31, 2015

2015-10-31 06:32:01: antoine commented


Trying to run just for more of a sense, it looks like there's some details required to set up the dbus server
[[BR]]
I have clarified this in the [/wiki/FAQ FAQ], start your server with:

dbus-launch xpra start ...

(but you probably have that already - that's not the problem, see below)
[[BR]]

Could not connect to D-Bus server .. without a $DISPLAY for X11
[[BR]]
You must tell it where to find the dbus server, either by running from within the xpra session or by setting the environment variables manually to point to that particular session if you are connecting via ssh or a console. (DISPLAY and/or DBUS_SESSION_BUS_ADDRESS depending on the tool used)

[[BR]]

Running qdbus --session org.xpra.Server /org/xpra/Server/13
..
When I try the same command from an xterm within the session, I just get the message Service 'org.xpra.Server' does not exist.
[[BR]]
Sorry about that. That's because I forgot to update this ticket, there were fixes and updates in: r10746, r10745, r10741, r10740, r11102.

In order to support multiple servers on the same system, we have to use a different service name for each server (but we can then use the same paths for each server). The number appended is the display number.
Try:

qdbus --session org.xpra.Server13 /org/xpra/Server
qdbus --session org.xpra.Server13 /org/xpra/Client1

I have updated the examples in comment:4 - you may need to force reload the page to get the update screenshot.
You can always use d-feet for exploring without needing to remember the service name, just search for "xpra" on the session bus.

Finally, it's worth mentioning that there is a new debug category for this: -d dbus.

@totaam
Copy link
Collaborator Author

totaam commented Nov 13, 2015

2015-11-13 19:12:33: maxmylyn changed status from reopened to closed

@totaam
Copy link
Collaborator Author

totaam commented Nov 13, 2015

2015-11-13 19:12:33: maxmylyn set resolution to fixed

@totaam
Copy link
Collaborator Author

totaam commented Nov 13, 2015

2015-11-13 19:12:33: maxmylyn commented


  • Using a Fedora 20 trunk 11211 client against a Fedora 21 11211 Server:
  • dbus commands appear to be working through d-feet (as best I can hand them arguments)

  • StartChild() will launch children fine

  • MoveWindowToWorkspace() also works. It was entertaining to move Firefox about. (Apparently I am easily entertained)

  • However, I cannot figure out how to assign a display properly to get it working through SSH.

  • I've been attempting unsuccessfully with:

[max@schlafanzug ~]$ export DISPLAY=:13
[max@schlafanzug ~]$ qdbus --session org.xpra.Server13 /org/xpra/Server
Service 'org.xpra.Server13' does not exist.

Update:

  • Added a DBUS_SESSION_BUS_ADDRESS (gotten from d-feet)
  • Found the session.

@totaam totaam closed this as completed Nov 13, 2015
@totaam
Copy link
Collaborator Author

totaam commented Nov 14, 2015

2015-11-14 07:14:59: antoine commented


Other possible ways of finding the value you need to use for DBUS_SESSION_BUS_ADDRESS:

  • env | grep DBUS_SESSION_BUS_ADDRESS from within the session
  • xpra info | grep DBUS_SESSION_BUS_ADDRESS
    (there may be more I can't think of)

@totaam
Copy link
Collaborator Author

totaam commented Apr 1, 2016

2016-04-01 13:06:47: antoine commented


See #486: we now have much better namespace support, so the data will come through in a much more structured format (needed fix in r12300), we also have a GetInfo which takes a subsystem as argument to reduce the amount of data returned

@totaam
Copy link
Collaborator Author

totaam commented Jun 14, 2017

2017-06-14 15:22:25: antoine commented


fix in r16067 for MouseClick, which can be used with:

gdbus call --session --dest org.xpra.Server1  --object-path /org/xpra/Server  --method org.xpra.Server.MouseClick 1 4 true 800 350 []
gdbus call --session --dest org.xpra.Server1  --object-path /org/xpra/Server  --method org.xpra.Server.MouseClick 1 4 false 800 350 []

This will send a scroll-up to window 1, with the mouse position at 800x350.

Beware:

  • my server is called "Server1" because it is on display 1
  • this dbus command must be executed from the session environment (or you would need to point it to the correct dbus instance)
  • each command may print some output, which can cause the xterm to scroll (and make it look like it failed to cause any scrolling)

@totaam
Copy link
Collaborator Author

totaam commented Jun 14, 2017

2017-06-14 20:48:02: antoine commented


As of 16074, the dbus interface for MouseClick is simplified:

MouseClick(button, pressed)

ie:

gdbus call --session --dest org.xpra.Server1  --object-path /org/xpra/Server  --method org.xpra.Server.MouseClick 4 true
gdbus call --session --dest org.xpra.Server1  --object-path /org/xpra/Server  --method org.xpra.Server.MouseClick 4 false

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

No branches or pull requests

1 participant