0

I'm a newbie in linux and I'll be glad for any help.
I'm using gdm and I want to execute a script **every time** a user login/logout .

To see that the mechanism works, I tried at first to execute the script for login only (and not logout).
I tried to run a service that does that by adding a service under /etc/systemd/user/serv.service.
Below is the Unit I wrote:

[Unit]
Description=service

[Service] type=oneshot RemainAfterExit=true ExecStart=/bin/bash /home/user/Documents/scriptlogin user=user

[install] WantedBy=default.target

I enabled the service by systemctl --user start serv.service,
and I see that the script is executed only on reboot, but not on login/logout.
I'm not sure I understand the default.target line, but I'm guessing the runlevel is not changed when user logout or login, so that's why the script is not running again when logout and login again.

Does anyone know how should I fix it?

Thanks in advance!

0 Answers0