Where to put game save files?

What is best practice where to put save game files from a snapped game?

If the snap is removed, the save files should stay. AFAICR the ~/snap/xxx/common directory gets deleted when you remove a snap so it is not a good place.

hey @A333,

I would recommend putting the game save files in

  • SNAP_USER_COMMON : (/home/<username>/snap/<snap name>/common)
  • SNAP_USER_DATA : (/home/<username>/snap/<snap name>/<revision>)

But after removing the snap the save files will be removed and there is no way around it other than manually copying the save file . As the documentation states

The data under /var/snap/<snap name>/ and /home/<username>/snap/ will be deleted. However, a copy is be retained as a snapshot for 30-days (except on Ubuntu Core systems), allowing data to be restored or manually retrieved.

I cant expect the users to manually backup/copy the save games. So SNAP_USER_COMMON and SNAP_USER_DATA are both unusable.

Another idea: Is there a hook/dialog when a snap is deleted - in order to give the player agency when they delete the snap?

Is it possible to write the save games to e.g. (/home/<username>/.local/share/snap/<snap name>/<revision>/)?

p.s. actually would be rather using the xdg base ($XDG_DATA_HOME/snap/<snap name>/…) rather than hardcoding the base path

p.p.s: cleaner would be to declare the save files not to be deleted on remove (only on --purge)

You can always create a non-hidden directory in $SNAP_REAL_HOME; that won’t get deleted if the snap is removed.