Systemd/User Services: Difference between revisions
mNo edit summary |
show how to enable a service for only specific users |
||
Line 47: | Line 47: | ||
You'll also likely want to change to {{ic|<nowiki>wantedBy = [ "multi-user.target" ];</nowiki>}} so the service starts at boot time. | You'll also likely want to change to {{ic|<nowiki>wantedBy = [ "multi-user.target" ];</nowiki>}} so the service starts at boot time. | ||
</translate> | </translate> | ||
== Enabling a service for specific users == | |||
By default, enabling a user service enables it for every user for which systemd spawns a service manager. If you wish for the service to be run only for specific users (say, {{ic|<nowiki>UserA</nowiki>}} and {{ic|<nowiki>UserB</nowiki>}}), use {{ic|<nowiki>ConditionUser</nowiki>}} ({{ic|<nowiki>man 5 systemd.unit</nowiki>}}): | |||
<syntaxhighlight lang="nix"> | |||
systemd.user.services.my-cool-user-service = { | |||
unitConfig.ConditionUser = "UserA|UserB"; | |||
}; | |||
</syntaxhighlight> | |||
[[Category:systemd]] | [[Category:systemd]] |