How can I get Snap to output files to /home directory


#1

I created a snap for Dosage, a simple command line comic downloader and archiver. I got it working but ran into an issue of where the files are stored. Dosage is supposed to create a folder named Comics in the home folder. My snap of Dosage created the Comics folder in home/mysnaps. How can I get the snape to save the jpgs to home/Comics? (I know about the home plug, but I’m not sure how to set it up.

Here is my snapcraft.yaml:

name: dosage # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
version: '2.15+git' # just for humans, typically '1.2+git' or '1.3.2'
summary: dosage is a comic strip downloader and archiver 
description: |
  dosage is a comic strip downloader and archiver written in Python
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  dosage:
    command: bin/dosage
    plugs: [home]

parts:
  dosage:
    source: https://github.com/webcomics/dosage.git
    source-type: git
    # See 'snapcraft plugins'
    plugin: python

#2

By default the snap’s HOME directory is set to ~/snap/_snap_name_/current, you can get the user’s real home directory by:

real_home_dir="$(
    getent \
        passwd \
        "${USER}" \
    | cut \
        --delimiter=: \
        --fields=6
)"

Then you can create your ~/Comics folder and whatsoever.


#3

I found the issue. It was putting the Comics folder in home/mysnaps/dosage because that was the directory my terminal was pointed to. I opened a fresh terminal (which defaulted to ~) and ran the dosage gocomics/foxtrot command. It downloaded the latest comic into /home/Comics.

Boy do I feel like an idiot.


#4

I figured out the issue. See above.