Ubuntu 24.04, Gnome flashback (metacity)
I've set the screen to blank after a period of inactivity (Settings/Power/Screen Blank). I want to run a script when the screen blanks. And another when I log on again.
There are solutions here
Execute a script upon a blank screen (screen off) in Ubuntu
How to run scripts on screen sleep / wake
but both rely on polling. Is there an event driven method, as there is for bootup and shutdown, and suspend and resume? Probably (ideally) using systemd.
If this isn't possible, I could use the HDD spinup/spindown state. I have set the HDD to spin down after an hour using hdparm settings. Is there an event-driven way to run scripts on spin-down and spin-up?