As discussed on IRC, it would be useful for systemd to lend a hand to applications that want to save state in the event that they crash.
1. Application will save state every 5/10 seconds when needed to its run-time directory
2. If the application crashes, systemd would move the application's state file to permanent storage under the data-dir.
3. If the application is closed properly, the state file would be removed
systemd could help by providing an equivalent to ExecStopPost that would move files with an app-specific name.
For example, totem saves a state playlist (including current playback position) to /run/user/1000/org.gnome.Totem/org.gnome.Totem.state.xspf. If totem crashes, then that file is moved to ~/.local/share/org.gnome.Totem/org.gnome.Totem.state.xspf so that it can re-read it when restarted.
<desrt> hadess: .local/share isn't going to get you invited to anybody's parties :)
Hmm, isn't this something dconf or so should cover instead?
THis would only protect against totem dying, but not against the system entirely dying...
(In reply to comment #2)
> Hmm, isn't this something dconf or so should cover instead?
dconf isn't there to store random blobs. systemd is the one that knows whether the application has crashed or quit correctly.
> THis would only protect against totem dying, but not against the system
> entirely dying...
True, but that would require us forcing a sync write to the disk, which is exactly what I'm trying to avoid.