tt
tt copied to clipboard
Export environment from service
Some daemons export configuration variables into the environment. I think it could be useful to provide support for this use-case into the configuration. An example could be SWAYSOCK variable exported by sway that is needed by all wayland related daemons, like Waybar and mako.
I propose to add:
- an
exportarray in theoptionssection to list all the environment to read once the service is started - an
importarray in theoptionssection to list all the service to import the environment from
Example:
sway.user:
[main]
name = sway
description = ...
type = longrun
[run]
build = path
execute = sway
[options]
export =[ SWAYSOCK ]
Waybar.user:
[main]
name = Waybar
description = ...
type = longrun
[run]
build = path
execute = waybar
[options]
import =[ sway ]
/proc/$pid/environ can be used to read the environment as shown here. Knowing the $pid of a service is at the base of the supervision used so it can be assumed that it is correct.
A couple of issues:
- Some services could want to export some dynamic environment variables to entire service tree of the user. E.g. a service could export all XDG environment variables. (for the static variable a different method should be added)
- Is reading from
/proc/$pid/environportable?