regolith-rofication
regolith-rofication copied to clipboard
Add automatic backup of the queue. Also, signal handling
Currently the queue is only saved when the program ends cleanly. But on crash, system reboot, etc, that never happens, and then system comes up with whatever we had on the queue when it was last saved.
This PR does two things:
- Capture signals, so for example SIGTERM is properly handled - we exit the GTK loop, we save the queue, we write a message.
- Make a backup of the queue every minute if needed. This could be made configurable but I don't think it's worth the trouble.
Tested by running the daemon from terminal, sending it SIGTERM, also keyboard interrupt, send notifications every few seconds to make the queue dirty and force a save, then don't send any additional notification to verify that it won't save unless needed.
Bonus: Also run black, which is why there's a few format changes in the files.