SNAP_REAL_HOME is kinda buggy

Answering one by one.

dosbox-staging and other snaps that I tested are snaps with grade: strict Means they are non-classic

Didn’t understand this question correctly? Can you make me that out?

Yes this is the case for non-classic snaps.

I have two main reasons for this,

  1. Apps where the user needs to pick some file from the file-chooser, if the HOME folder takes them to somewhere else, then it’ll be very confusing for them that to access files saved in the /home/$USER, they need to click on their username on the top bar of the file manager.
  2. I am recently snapping an app which saves the config file of my current desktop as a backup. And when needed, they can restore them. The app is savedesktop I am talking about. It needs the correct home path for that purpose. Also, currently the portal is not working with snaps, so, this is the only alternative left, which needs to bug free for now. This is the forum post I’m talking about.

My current

snaapcraft.yaml
name: savedesktop # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '1.8.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
slots:
  gnome-dbus:
    interface: dbus
    bus: session
    name: org.gnome.SessionManager
  xfce-dbus:
    interface: dbus
    bus: session
    name: org.xfce.SessionManager
parts:
  savedesktop:
    # See 'snapcraft plugins'
    plugin: dump
    source: https://github.com/vikdevelop/SaveDesktop.git
    source-tag: $SNAPCRAFT_PROJECT_VERSION
    override-pull: |
      craftctl default
      sed -i 's|Icon=io.github.vikdevelop.SaveDesktop|Icon=usr/share/icons/hicolor/128x128/apps/io.github.vikdevelop.SaveDesktop.png|' flatpak/io.github.vikdevelop.SaveDesktop.desktop
      sed -i 's|locale = open(f"/app/translations/{lang}")|locale = open(f"/snap/savedesktop/current/usr/translations/{lang}")|' src/main_window.py
      sed -i 's|~/|/home/$USER/|' -i src/main_window.py
      sed -i 's|~/.config|/home/$USER|' -i src/main_window.py
      sed -i 's|/app/main_window.py|/snap/savedesktop/current/usr/main_window.py|' run.sh
    override-build: |
      craftctl default
      install -Dm755 -t ${CRAFT_PART_INSTALL}/usr/bin/ run.sh
      install -Dm755 -t ${CRAFT_PART_INSTALL}/usr/ src/main_window.py
      install -D -t ${CRAFT_PART_INSTALL}/usr/share/applications flatpak/io.github.vikdevelop.SaveDesktop.desktop
      install -D -t ${CRAFT_PART_INSTALL}/usr/share/icons/hicolor/128x128/apps flatpak/icons/io.github.vikdevelop.SaveDesktop.png
      install -D -t ${CRAFT_PART_INSTALL}/usr/share/icons/hicolor/128x128/apps flatpak/symbolic-icons/exclamation_mark.png
      install -D -t ${CRAFT_PART_INSTALL}/usr/share/metainfo flatpak/io.github.vikdevelop.SaveDesktop.metainfo.xml
      cp -R translations ${CRAFT_PART_INSTALL}/usr/
apps:
  savedesktop:
    command: usr/bin/run.sh
    desktop: usr/share/applications/io.github.vikdevelop.SaveDesktop.desktop
    common-id: io.github.vikdevelop
    extensions: [ gnome ]
    plugs: [ home ]

file for savedesktop