[Unit] Description=Backup PH_USER's Firefox profile before shutdown DefaultDependencies=no Before=halt.target shutdown.target reboot.target poweroff.target # A drop-in with Requires=X.mount may come handy if the target is not the root volume [Service] Type=oneshot User=PH_USER ExecStart=/usr/bin/true ExecStop=PH_DIRECTORY/firefox-backup.sh RemainAfterExit=yes [Install] WantedBy=default.target