You are not logged in.

#1 2021-05-04 11:10:36

Yann
Member
Registered: 2017-11-23
Posts: 235

[Systemd] Manage service to kill itself at event

Hi everyone,

I am fighting a little with systemd and finally got a working unit service. This is a user unit under ~/.config/systemd/user/mem.service meaning to regularly update the memory information in my i3 status bar.

[Unit]
Description=Memory bar display
After=network.target multi-user.target graphical-session.target
Requires=graphical-session.target

[Service]
Type=simple
EnvironmentFile=%h/.local/share/env/paths
ExecStart=%h/.pyenv/shims/python %h/dev/python/bar_display/Memory.py
StandardOutput=append:%h/env.log
StandardError=append:%h/env.log

[Install]
WantedBy=graphical-session.target

I observed that the service doesn't get killed when I kill i3 and the Xorg server. I then understand that the After and Requires parameters are dependencies only for the start process but not for the running.
This process only makes sens when i3 is started, how can I tell systemd to finish this process when i3 is killed ? Should I run i3 as a systemd service to ?

Less importantly, how can I create a folder in ~/.config/systemd/user/ to put this particular service unit and still be able to start it with systemctl --user start mem.service ?

Is my general way to do good ?

Thanks for your time.


all different - all equal

Offline

Board footer

Powered by FluxBB