Skip to content

Commit

Permalink
Add an example for user systemd service (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
martbab authored Aug 27, 2022
1 parent 29d4c43 commit d222c2c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,22 @@ details, see syntax at https://goo.gl/R74nmi). If an arg is specified in more
than one place, then commandline values override config file values which
override defaults.
```

### Per-user systemd service
Copy the systemd service file from `systemd-user` folder to a location
suitable for user-defined systemd services (typically
`$HOME/.config/systemd/user`).

Modify the `WorkingDirectory` directive to point to the location of the
installation, and `ExecStart` directive to configure how `fake.py` is run.

To start the service and enable it so that it is run after login, run the
following (as normal user):
```
$ systemctl --user start fakecam.service
$ systemctl --user enable fakecam.service
```

## License
The source code of this repository are released under GPLv3.

Expand Down
26 changes: 26 additions & 0 deletions systemd-user/fakecam.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# systemd user unit file for Linux-Fake-Background-Webcam
# place this file into a location suitable for user-defined systemd units
# (e.g $HOME/.config/systemd/user)
#
# To enable and run the fakecam service, run
# systemctl --user enable fakecam.service
# systemctl --user start fakecam.service

[Unit]
Description=Fake camera
After=network.target

[Service]
Type=simple
# specify working directory such as Git project directory
# %h expands to the $HOME directory of the user running the service
WorkingDirectory=%h/devel/fangfufu/Linux-Fake-Background-Webcam
# you can use command line options here, or point the script
# to your config file
ExecStart=python3 fake.py -c %h/.config/fakecam/config.ini
# fake.py exits when pressing Ctrl + \ which corresponds to SIGQUIT
# so we need to specify this kill signal instead of SIGINT
KillSignal=SIGQUIT

[Install]
WantedBy=default.target

0 comments on commit d222c2c

Please sign in to comment.