dbus

dbus-send to remote machine

别来无恙 提交于 2019-12-08 02:43:33
问题 What's the syntax for sending a dbus message to another machines dbus daemon using dbus-send? I see there's TCP/IP support for the destination address, but I can't find any docs on how to actually specify the address. 回答1: Override the session bus address using the environment variable: DBUS_SESSION_BUS_ADDRESS=tcp:host=server.example.org,port=77777 dbus-send ... Note that the buses running by default do not listen on TCP. You have to run your own bus instance for that. 来源: https:/

How to reply a D-Bus message

*爱你&永不变心* 提交于 2019-12-08 02:05:54
问题 I got the D-Bus server.c and client.c code, and made some modification. I want the result that when type for example "hi" from client.c server will print "receive message hi", and reply "reply_content!!!!!!" to client.c But it seems that now client.c cannot get the reply message. Anyone have the idea? Thanks in advance. "server.c" /* server.c */ #include <dbus/dbus.h> #include <stdbool.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> static DBusHandlerResult filter_func

Start the session bus of DBus with Perl Net::DBus

烂漫一生 提交于 2019-12-08 00:39:32
问题 I am using Perl and the Net::DBus module. I wrote a simple test program: #!/usr/bin/perl use strict; use warnings; package MyObj; use Net::DBus::Exporter qw(org.example.Tao); use base qw(Net::DBus::Object); sub new { my $class = shift; my $service = shift; my $self = $class->SUPER::new($service, '/MyObj'); bless $self, $class; return $self; } dbus_method("Hello", ["string"]); sub Hello { return 'Hello'; } package main; use Net::DBus; use Net::DBus::Reactor; my $bus = Net::DBus->session; my

Getting Notified on “Ethernet cable plugged in” events in linux

旧城冷巷雨未停 提交于 2019-12-07 19:39:42
问题 I am writing a Python Application running on linux. I want to be able to register and be notified by the system if a network cable is plugged in/ out . I am already using pyUdev (python bindings for libUdev) in order to get notified for USB plug in events. However, because the network eth0 module (for example) always remains loaded (regardless of the cable being plugged in) , I dont get the information I require. It only works for if up/down events. I have read a lot of posts on Windows WMI

DBUS APIs in BLUEZ

倖福魔咒の 提交于 2019-12-07 16:49:01
问题 I am new to BLUEZ as well as linux. I found that Bluez promotes usage of DBUS APIs. I want to know whats a DBUS API in terms of BLUEZ also, whats the benefit of using them instead of direct C APIS? How different is it as compared to C APIs? 回答1: From my own experience: DBUS apis are the officially published ones so are more likely to be stable, maintained and documented. The C apis are a bit more low level and it's not always obvious how they can be used (beyond simple discover). The C apis

Vala and PolicyKit

不问归期 提交于 2019-12-07 13:38:24
问题 I'm creating a simple GTK+ based application in Vala, which should be able to write into system directories, so it needs root access. I realize that giving full root access is a bad idea, so I need a way to gain temporary privileges. In theory, the PolicyKit D-Bus service is the tool for the job, but I have no idea how to use it, let alone in Vala code. Any insight would be appreciated. update: I have done some further digging. My starting point was this. So basically what I need is finding

Calling dbus-python inside a thread

会有一股神秘感。 提交于 2019-12-07 09:31:49
问题 I'm getting segfaults when calling a dbus method inside a thread. This is my scenario: I have a program Service1 that exposes a method test. A second program Service2 exposes a method expose. As this method does some serious numerical computation, I pass some params from expose to a running thread reader. This thread, in turn, calls the method test of Service1 when it ends its work. I'm geting segfaults in last dbus call. The code: # Service1.py class Service1(Object): def __init__(self, bus)

qdbusxml2cpp unknown type

我的梦境 提交于 2019-12-07 05:46:33
问题 While using the qdbusxml2cpp program to convert the following xml to a Qt Class, I am getting this error: qdbusxml2cpp -c ObjectManager -a ObjectManager:ObjectManager.cpp xml/object_manager.xml Got unknown type `a{oa{sa{sv}}}' You should add <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="<type>"/> to the XML description D-Feet description: XML: <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0

Linux Shutdown with dbus-send

喜欢而已 提交于 2019-12-07 05:13:35
问题 I am writing a Java app to shutdown my Linux box remotely. The desktop app sits and waits for a command to be sent to it. I have tried using "shutdown -h" but this requires sudo privileges and is not an option. I then found a way to shutdown without sudo using the following dbus-send solution: dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown This works fine but I am trying to figure out,

Unit文件编写,编写服务脚本

删除回忆录丶 提交于 2019-12-07 04:31:19
Unit文件编写参考链接: https://www.freedesktop.org/software/systemd/man/systemd.service.html Unit基础介绍 Unit文件可以从多个位置加载,常见位置如下(优先级 低—>高 ): /usr/local/lib/systemd/system/ :软件包安装后的unit /etc/systemd/system/ :系统管理员安装的unit 备注: ·systemd 单元名仅能包含 ASCII 字符,下划线和点号和有特殊意义的字符('@', '-')。其它字符需要用 C-style "\x2d" 替换。 ·当 systemd 运行在用户模式下时,使用的加载路径是完全不同的。 · 以 # 开头的注释可能也能用在 unit-files 中,但是只能在新行中使用,在systemd的参数后面使用行末注释,则 unit 将会启动失败。 查看加载的位置 # systemctl show --property=UnitPath Unit中的依赖关系处理 使用 systemd 时,可通过正确编写单元配置文件来解决其依赖关系。典型的情况是,单元 A 要求单元 B 在 A 启动之前运行。在此情况下,向单元 A 配置文件中的 [Unit] 段添加 Requires=B 和 After=B 即可。若此依赖关系是可选的,可添加 Wants