I have a very simple script that I want to run every time I shut down my computer.
How can the script be automatically executed once I press the 'Shut Down' or 'Restart' button?
elementary OS Stack Exchange is a question and answer site for developers and users of elementary OS and applications. It only takes a minute to sign up.Sign up to join this community
Unfortunately I don't know of a real graphical way to achieve that.
But because elementary is based on Ubuntu and thus uses systemd, you should be able to do it with a systemd service. Basically create a file
/etc/systemd/system/myshutdown.service with something like that:
[Unit] Description=Do something on shutdown [Service] Type=oneshot RemainAfterExit=true ExecStart=/bin/true ExecStop=/path/to/your/script [Install] WantedBy=multi-user.target
Then enable it with:
systemctl enable myshutdown