I want to bind a user systemd timer (or service) to network events. For example consider this service:
[Unit] Description=shows if connection changed [Service] Type=oneshot Environment=DISPLAY=:0 ExecStart=notify-send "Network" "Status changed!"
How can I force this user service to run on network up/down events?
I asked a similar question before. It seems I should use the
PartOf= directive but what target should I use for this?
1- Note that I've defined this service in
~/.config/systemd/user/ so its scope is user-level. That means it can't depend on system targets.
2- If we define it as a system-level service, what is the proper hook (.target) that causes this service to trigger?
I've monitored system service when I toggle the WiFi switch. Only
NetworkManager-dispatcher.service gets triggered on such event and after doing its task, it gets de-activated. So it seems I can't depend on it.
network-manager.service are all loaded and active even when I turn off system's WiFi.