[BRLTTY] Systemd service autostart

Mario Lang mlang at delysid.org
Thu Aug 27 04:00:59 EDT 2015


Dave Mielke <dave at mielke.cc> writes:

> [quoted lines by Samuel Thibault on 2015/08/26 at 02:09 +0200]
>
>>Apparently, udev rules can be made to start a systemd service with
>>ENV{SYSTEMD_WANTS}="brltty.service"
>
> Would we still need two udev.rules files - one to have systemd start brltty, 
> and one to have udev start it? Might there be a way to have only one?

There is a way to test if udev is running as part of systemd.
So the way to go if we want to keep backward compatibility and just one
rule file is to use gotos.  Here is an example from usbmuxd:

TEST=="/run/systemd/system/", ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="05ac", \
TAG+="systemd", ENV{SYSTEMD_WANTS}="usbmuxd.service", ... GOTO="systemd_end"

There is a few things I am still unsure about.  We need to pass the device
usb serial number to the brltty.service such that the correct device is
grabbed in case several are connected (which, for me, is actually the
main selling point of enabling support for launching BRLTTY upon USB
device connection. It will allow to have several displays connected to a
single computer without manually needing to start extra brltty
instances).  I guess we can set environment variables to contain the
device serial, but I am not sure if the systemd service unit syntax is
flexible enough to only pass along the USB serial if it is actually
set.  IOW, the brltty.service file needs to pass -d usb:$serial in case
it was activated from udev, otherwise, it shouldn't pass a -d at all.
Or maybe just use -E in ExecStart and set BRLTTY_BRAILLE_DEVICE in the
udev rule?

P.S.: I am actually a bit disapointed about the udev/systemd
integration.  I was kind of expecting a .usb unit that would just let
us list a number of USB IDs, so that the user can selectively
enable brltty.usb or brltty.service, just as they would do with
ssh.service and ssh.socket.  However, it doesn't appear to work that
way, and udev feels very much like a tool pulled into the ecosystem of
systemd without a lot of real integration.  What I can gather from the
docs I have read so far, systemd is supposed to generate a brltty.device
unit file automatically if TAG+="systemd" is used.  How this
brltty.device unit file would be used in systemd exactly, isn't really
clear to me yet.

-- 
CYa,
  ⡍⠁⠗⠊⠕


More information about the BRLTTY mailing list