How do I setup a systemd service to be started by a non root user as a user daemon?
systemd normally does not allow ordinary users to start system services. While it does support giving access via polkit, that part is still somewhat lacking, and you cannot yet allow only one specific service.
(Edit: Later systemd versions do support it, but only with polkit v106 or later.)
Since rtorrent is not actually a system service, and because you want every user to have their own instance of rtorrent, experiment with systemd's "user" mode.
When you log in, the system will start a user@<uid>.service
system unit for you, which will launch a separate "--user" instance of systemd. The new user-systemd will read unit files (starting with default.target
) from ~/.config/systemd/user/
, /etc/systemd/user/
and /usr/lib/systemd/user/
.
Related videos on Youtube
Elson Kwek
Updated on September 18, 2022Comments
-
Elson Kwek over 1 year
I told myself to never ask
common sense
ornovice
questions if I can look it up on the web and to resort to asking people as the last resort. This will probably be a fundamental question but please do enlighten me!My code :
obj = pm.ls (selection=True,sn=True,o=True) # get selection = obj shapes = pm.listRelatives(obj) # get obj shapeNode name cpmNode = pm.createNode('closestPointOnMesh') # create closestPointOnMesh Node pm.setAttr(shapes+".outMesh",cpmNode + ".inMesh") # setattr selection shapeNode to cpmNode inMesh
Error :
# Can only concatenate list (not "str") to list
I don't understand how
pm.setAttr(shapes+".outMesh",cpmNode + ".inMesh")
is making into a list. Isn't it a command with strings now?And by putting
shapes
intopm.setAttr(shapes+".outMesh",cpmNode + ".inMesh")
is giving me errors where.outmesh
is a string?Is
pm.setAttr(shapes+".outMesh",cpmNode + ".inMesh")
a list then?How should I make my current selection shapeNode to change
pCubeShape1
if given example (below):pm.setAttr("pCubeShape1.outMesh",cpmNode + ".inMesh")
-
Hans over 11 yearsI realize that one could create a separate service file per user, and simply enable it. However I just want to know if it could be possible the way I have described it above.
-
Hans over 11 yearsFair enough, I could simple setup
sudo
for the users and have them, as mentioned in my comment above, control their own service file. However this solution would allow the user to control most other services as well... -
user1686 over 11 yearsIt wouldn't, if you had read
sudo
's documentation – sudoers(5) has many examples on restricting a command's arguments. -
bla over 6 years
shapes = pm.listRelatives(obj)
probably returns a list. And[] + 'any_string'
gives me the same error you are having. -
Elson Kwek over 6 yearswell i do know we cant do list and string together. What i dont understand is where the hell is the list coming from lol. From what i understand,
shapes = pm.listRelatives(obj)
should be a string. i am trying to insert this "string" into"pm.setAttr(shapes+".outMesh",cpmNode + ".inMesh")"
where this is a list if i am nt wrong -
warcholprzemo over 6 yearsmaybe you try print type(shapes), type(cpmNode) so you figure out if objects are string or list. You can use pdb module too for trying possibilities on running code.
-
Elson Kwek over 6 yearsWhile perhaps the suggestion by @warcholprzemo is great, print type(shapes) tells me that shapes is a list. Perhaps I should rephrase my question to get a straight route to what i want to achieve.
cmds.connectAttr("polyShape.outMesh", cpmNode + ".inMesh") #replace polyShape with your shapeNode's name
Code fromhttps://www.aganimator.com/tutorials/2016/3/1/cpointmesh-npointcurve
How or what ways should i approach changing the shapeNode name with my current selection given that "polyShape.outMesh" is being unicoded?
-
-
Hans over 11 yearsThanks grawity, that was basically what I was missing. However it also turns out to have been a DBus problem as well: there seems to be a bug in dbuse that doesn't set the correct global variable
DBUS_SESSION_BUS_ADDRESS
for a given user, so systemctl can't access the user session, it errors our. Once I figured out this small problem, everything else works beautifully! -
Elson Kwek over 6 yearsThank you @Green Cell. This is the solution I have been looking for! Looks like there's a difference between set and connect Attr. I will study more on it and most appreciated for the kind explaination! Pardon me for the limited knowledge i have atm XD
-
Green Cell over 6 yearsThink of
setAttr
as a one time operation, whereconnectAttr
would be something that sticks and calculates during playback (a connection between the two nodes). Generally if it needs to be done in the connection editor then it'sconnectAttr
-
Bojan P. about 2 years@Hans and what was the solution to setting
DBUS_SESSION_BUS_ADDRESS
? This problem still persist... -
Hans about 2 years@BojanP. see my UPDATE2 in the question, basically
DBUS_SESSION_BUS_ADDRESS
should be set to a user specific dbus socket.