Orchestrating singleshoot services, dependent services, desktop files and ports as a user
0
votes
0
answers
27
views
I am not sure how to title this, but essentially, I am looking for advice on to how to best implement the following. The specifics I can search online, but I am not sure how to glue it.
I am trying to write a
.destkop
file that will call the command uxplay
(AirPlay Unix mirroring server) and put a system trey icon with a Quit
menu entry. uxplay
needs a couple of ports open, additionally, it requires a "DNS-SD Server". I am not familiar with that term, but it seems something like avahi
is what I need.
So high level this is what I imagine:
1. Launch the desktop file, via Krunner
or Rofi
.
2. The desktop file's Exec
calls a script that will do two things:
- Start a systemd
user service.
- Launch yad
(Yet Another Dialogue) with a menu entry called Quit
that then stops that user service.
3. The user service's Require
and After
will launch the avahi
service.
4. The user service will then somehow open the required ports, maybe in its ExecStart
. This part I am not so sure, because I think that would require root
, could it somehow use a policy kit thing to display that dialogue in the desktop which provides privileges?
5. uxplay -p
is finally called via Exec
.
When we quit:
- ExecStop
closes the ports (can I somehow persist the same privileges, so I don't have to policy kit again?)
- Due to avahi
's service PartOf
clause, when uxplay.service
stops, so does avahi.service
If there are better ways I am happy to scrap all of this, it is simply the best I could come up with, although again, I am not even sure the ports section can be implemented inside a user service unit.
Asked by Mathias Sven
(273 rep)
Oct 15, 2024, 02:29 PM