DBus service

AsamK edited this page Sep 20, 2017 · 3 revisions

signal-cli can run in daemon mode and provides an experimental dbus interface. For dbus support you need jni/unix-java.so installed on your system (Debian: libunixsocket-java ArchLinux: libmatthew-unix-java (AUR)).

  • Run in daemon mode (dbus session bus)

        signal-cli -u USERNAME daemon
    
  • Send a message via dbus

        signal-cli --dbus send -m "Message" [RECIPIENT [RECIPIENT ...]] [-a [ATTACHMENT [ATTACHMENT ...]]]
    

System bus

To run on the system bus you need to take some additional steps. It’s advisable to run signal-cli as a separate unix user, the following steps assume you created a user named signal-cli. To run a service on the system bus, a config file is needed to allow the signal-cli user to take a name on the system bus. An example config file can be found in data/org.asamk.Signal.conf. This file also configures that any user can talk with the signal-cli daemon. The data/org.asamk.Signal.service and data/signal.service files configure a dbus activated systemd service for signal-cli, so the service is automatically started when the dbus service is requested.

These steps, executed as root, should work on all distributions using systemd.

cp data/org.asamk.Signal.conf /etc/dbus-1/system.d/
cp data/org.asamk.Signal.service /usr/share/dbus-1/system-services/
cp data/signal.service /etc/systemd/system/
sed -i -e "s|%dir%|<INSERT_INSTALL_PATH>|" -e "s|%number%|<INSERT_YOUR_NUMBER>|" /etc/systemd/system/signal.service
systemctl daemon-reload
systemctl enable signal.service
systemctl reload dbus.service

Mind the fact that signal.service executes the signal-cli with "--config /var/lib/signal-cli". If you registered with user signal-cli, remove the config option.

Make sure to use "--dbus-system" with the send command, the service will be autostarted by dbus the first time it is requested.

To avoid the startup time of the JVM for the dbus client, you can use any dbus capable program to send messages via the signal-cli dbus daemon. Example with dbus-send:

dbus-send --session --type=method_call --print-reply --dest="org.asamk.Signal" /org/asamk/Signal org.asamk.Signal.sendMessage string:MessageText array:string: string:RECIPIENT