Real user $HOME dir

The $HOME environment variable is overwritten by the snap to point to the snap directory, not the user’s home directory. This makes sense and works in most cases. I added the home plugin so my snap can read the homefolder.

Is there are smart way to point to the real user’s homedir? I can’t hardcode /home/fiber/ in my wrapper script.

I tried using /home/$(whoami) but that doesn’t seem to work:

/snap/.../my.wrapper: 4: /snap/.../my.wrapper: whoami: Permission denied

Instead of /home/$(whoami), try with:
$(getent passwd $UID | cut -d ':' -f 6)


Note that there is now a helpful environment variable (SNAP_REAL_HOME) that snapd will provide you which is a bit easier to use:

$ snap run --shell hello-world
user@localhost:/home/user$ echo $HOME
user@localhost:/home/user$ echo $SNAP_REAL_HOME

This requires a recentish snapd, I think snapd 2.46+ or thereabouts


Any related to Gtk file explorer does not show removable media in left pane ( the last bit about personal folder ) ?