surface-dtx-daemon icon indicating copy to clipboard operation
surface-dtx-daemon copied to clipboard

OpenRC Support

Open parinzee opened this issue 3 years ago • 9 comments

Hi, I've taken a look at the source code for this. Would it be possible to add OpenRC support to it? From the looks of it, we only need a OpenRC service file. I am happy to write this up, however, are there any more aspects of this that depend on SystemD?

Sincerely, Parin

parinzee avatar Apr 25 '21 02:04 parinzee

I don't see why OpenRC wouldn't work. There's no hard dependency on systemd from the actual executables, only on D-Bus. Keep in mind though that the system service should be started after the DTX device is available (this udev rule helps with that for the systemd service).

Feel free to send a PR.

qzed avatar Apr 25 '21 12:04 qzed

Right thank you for the reply, I'll report the progress back in a few days.

parinzee avatar Apr 25 '21 13:04 parinzee

My take on it so far:

#!/sbin/openrc-run

command="/usr/bin/surface-dtx-userd"
command_args="--no-log-time"
pidfile="/run/${RC_SVCNAME}.pid"

depends ()
{
	after surface-dtx-daemon
}


#!/sbin/openrc-run

command="/usr/bin/surface-dtx-daemon"
command_args="--no-log-time"
pidfile="/run/${RC_SVCNAME}.pid"

depends ()
{

}

werdahias avatar Nov 28 '21 21:11 werdahias

forgot the name section

werdahias avatar Nov 28 '21 21:11 werdahias

Interesting:

sudo rc-service surface-dtx-userd start
 * surface-dtx-userd: waiting for surface-dtx-daemon (50 seconds)
 * Starting surface-dtx-userd ...
 INFO sdtxu: running...
ERROR sdtxu: critical error: Failed to connect to D-Bus (session)

Error: Failed to connect to D-Bus (session)

Caused by:
    Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
 * Failed to start surface-dtx-userd                                                                                                                                        [ !! ]
 * ERROR: surface-dtx-userd failed to start

surface-dtx-daemon.txt surface-dtx-userd.txt

werdahias avatar Nov 28 '21 21:11 werdahias

The general idea behind the two daemons is: The system daemon is responsible for detaching whereas userd is a per-user daemon that takes care of notifying the user (e.g. when the clipboard can be detached). They need a D-Bus interface as they're communicating over that. The user-daemon also sends notifications to the user via D-Bus interface.

I have no idea how OpenRC works exactly, but you have to launch the userd as any user that wants to be notified, not as root. In general, this also makes only sense for any user that has a graphical interface as the userd is essentially only for notifications.

qzed avatar Nov 28 '21 22:11 qzed

Can confirm dtx is working when just invoking dtx-daemon using above init script. I've deactivated userd for now.

werdahias avatar Nov 28 '21 23:11 werdahias

Interesting:

sudo rc-service surface-dtx-userd start
 * surface-dtx-userd: waiting for surface-dtx-daemon (50 seconds)
 * Starting surface-dtx-userd ...
 INFO sdtxu: running...
ERROR sdtxu: critical error: Failed to connect to D-Bus (session)

Error: Failed to connect to D-Bus (session)

Caused by:
    Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
 * Failed to start surface-dtx-userd                                                                                                                                        [ !! ]
 * ERROR: surface-dtx-userd failed to start

surface-dtx-daemon.txt surface-dtx-userd.txt

@CountOmega

Looks like surface-dtx-userd depends on dbus. But that couldn't start without an x server. Perhaps userd can be launched after your WM/DE?

parinzee avatar Nov 29 '21 02:11 parinzee

yeah still have to check it out. With above service file for surface-dtx-daemon it is stuck at starting and doesn't work. When I launch the service manuallly, it starts, and is working, but the command keeps running. If if ctrl +c it after some time it stops, obviously.


sudo rc-service surface-dtx-daemon status
 * status: starting

sudo rc-service surface-dtx-daemon stop
 * Call to flock failed: Resource temporarily unavailable
 * ERROR: surface-dtx-daemon stopped by something else

sudo rc-service surface-dtx-daemon restart
 * Starting surface-dtx-daemon ...
 INFO sdtxd: running...

Really strange.

werdahias avatar Nov 29 '21 05:11 werdahias