dbus

Connect to session DBus on different computer

一曲冷凌霜 提交于 2019-12-24 13:08:11
问题 I can run my Qt DBus test by connecting to the session bus: QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerService(...) .... TestserviceInterface testserviceInterface( .... , connection, &a); But can I connect to this DBus from a different computer. I know I can do something like this: connection = QDBusConnection::connectToPeer("tcp:host=127.0.0.1,port=45000", Testservice::ServiceName); But how would I obtain the port? Whatever I have tried, there seems to be

Parse a variant array using command line utils in bash

让人想犯罪 __ 提交于 2019-12-24 10:26:47
问题 To get the current song being played in spotify (using DBus), I use the following command: dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' Now, the output of the command below is like: (stripped down for clarity) variant array [ dict entry( string "xesam:artist" variant array [ string "The Black Keys" ] ) dict entry( string "xesam:title" variant string

How to use Python Dbus bindings in Anaconda

对着背影说爱祢 提交于 2019-12-24 02:57:11
问题 I am trying to install dbus on Anaconda python environment and I am struggling. Here is the error message I am getting: e@gateway:~$ python Python 3.5.4 |Anaconda custom (64-bit)| (default, Oct 13 2017, 11:22:58) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import dbus Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/e/anaconda3/lib/python3.5/site-packages/dbus/__init__.py", line 77, in <module> import dbus

A tool to pass struct to dbus method?

ε祈祈猫儿з 提交于 2019-12-23 20:21:14
问题 I've created a daemon. The daemon provides a dbus interface, with one of its methods having a signature like this (uu) -- that is a struct of two uint32 fields. Is there a ready-to-use tool for me to invoke the method, to pass the struct in? dbus-send and d-feet doesn't seem to help. Any pointers? 回答1: gdbus should do the trick. Try the equivalent of: gdbus call --session --dest com.example.MyTest --object-path /com/example/MyTest --method com.example.MyTest.Test "(1,2)" ... with the correct

How to stop a dbus gobject loop

社会主义新天地 提交于 2019-12-23 19:38:07
问题 I try to stop a gobject.MainLoop() after a few seconds. I don't know if it's possible to set a timeout to this kind of loop, it would be perfect but I have not found that. So, I tried to workaround this with threading but unfortunately, the main loop block others threads. Here my code (I'm working with python 2.7): import MediaCenter_dbusConfig import dbus import gobject from dbus.mainloop.glib import DBusGMainLoop from time import sleep from threading import Thread mainloop=0 class Timeout

How to get device name with D-Bus?

匆匆过客 提交于 2019-12-23 05:15:48
问题 I develop an application in C++ on Linux, which interacts with blueooth devices (such as bluetooth sockets or speakers). I use D-Bus command to get list of paired devices: dbus-send --system --dest=org.bluez --print-reply $BTADAPTER org.bluez.Adapter.ListDevices It returns: method return sender=:1.0 -> dest=:1.90 reply_serial=2 array [ object path "/org/bluez/489/hci0/dev_00_1F_C5_75_45_5E" object path "/org/bluez/489/hci0/dev_F0_13_C3_00_A1_08" object path "/org/bluez/489/hci0/dev_00_11_12

How to Pass a structure as a parameter in a dbus signal?

坚强是说给别人听的谎言 提交于 2019-12-23 04:34:45
问题 How to pass a structure as a parameter to a dbus signal through command line? Dbus-send --system --type=signal / com.example.signal_name string:"hello" In the place of string, I want to pass structure foo. typedef enum {MODE1, MODE2, MODE3} MODE; typedef enum {TYPE1, TYPE2} TYPE; struct foo { MODE mode; TYPE type; }; 回答1: Firstly, you need to work out how to represent that structure as a D-Bus value. Its most likely representation would be as a value of type (uu) where the first u is the mode

Unable to autolaunch a dbus-daemon without a $DISPLAY for X11. NetBeans. Pi as remote host

为君一笑 提交于 2019-12-22 00:34:10
问题 I am trying to run the following example code using my NetBeans IDE: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <dbus/dbus.h> int main() { DBusConnection *connection = NULL; DBusError error; char buffer[1024]; dbus_error_init(&error); connection = dbus_bus_get(DBUS_BUS_SESSION, &error); if (dbus_error_is_set(&error)) { fprintf(stderr, "%s", error.message); abort(); } puts("This is my unique name"); puts(dbus_bus_get_unique_name(connection)); fgets(buffer, sizeof

How do I use Emacs's DBUS interface?

心不动则不痛 提交于 2019-12-20 18:33:48
问题 I looked up the dbus package and it seems like all of the functions are built-in to the C source code and there's no documentation for them. How do I use the dbus-call-method function? 回答1: Google to the rescue... Follow the link for the example, it's not my code so I won't put it here. http://emacs-fu.blogspot.com/2009/01/using-d-bus-example.html 回答2: I just had the same problem and found the emacs-fu article that comes up when googling a little too basic for my needs. In particular I wanted

DBUS客户端程序

妖精的绣舞 提交于 2019-12-20 07:16:17
DBUS客户端程序,发送一个信号,信号携带int型数据。信号的object path为"/test/signal/server",interface名为 "test.signal.Type",信号名为"Test"。接收端可以根据这三个属性来判断是否是想接收的信号。 使用dbus前要建立一个连接,通过这个连接连到dbus总线。DBusConnection *dbus_bus_get (DBusBusType type, DBusError *error) 函数就是建立连接用的。第一个参数为dbus连接类型,分为DBUS_BUS_SESSION(会话总线)和DBUS_BUS_SYSTEM(系统总线)。第二个参数用来返回错误消息。返回结果是与dbus建立的连接。 连接建立好了,为了方便使用需要给它起个名字,用dbus_bus_request_name()函数。 dbus_message_new_signal()用来创建一个信号。有个信号还需要往里添加数据。我把DBusMessageIter相当于一个数据容器指针。然后使用dbus_message_iter_init_append()将信号和数据指针挂上关系。然后往DBusMessageIter里挂数据,间接的往信号里放数据。再使用dbus_connection_send()把数据发出去,剩下的就等着接收端收了。 dbus