Trying to make my first snap

Hi all,

I am trying to learn how to make some simple snap packages. I more or less randomly chose pulsemixer because it is a neat little tool, self-contained, but has a system dependency, libpulse0 and needs access to some system functionality (pulseaudio).

I made a fork here with the current state of affairs, but if that just worked I wouldn’t be here :stuck_out_tongue:

For reference, currently the snap/snapcraft.yaml looks like this:

name: pulsemixer # you probably want to 'snapcraft register <name>'
version: '1.2.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: cli and curses mixer for pulseaudio # 79 char long summary
description: |
  pulsemixer allows control of pulseaudio both via command-line arguments and with a colourful curses interface.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

    command: pulsemixer
    plugs: [pulseaudio]

    # See 'snapcraft plugins'
    plugin: python
    stage-packages: [libpulse0]

I connected the pulseaudio interface as described in the docs and made a wrapper script that sets the PULSE_RUNTIME_PATH and PULSE_SYSTEM variables as mentioned there. But all I get after installing is

Failed to create secure directory (/var/run/pulse): Permission denied
Failed to connect to pulseaudio daemon: Connection refused

The first error comes from the wrapper script, the second one from the python script itself, that is, I also get that one if I replace the in the apps>pulsemixer>command section of snapcraft.yaml with pulsemixer itself.

So I’m a bit stuck here. My immediate questions are:

  1. Is installing libpulse0 via stage-packages the right thing to do? It drives up the install size to about 2.8MB, which strikes me as quite a lot for this application, but I could live with it.

  2. Are the docs for accessing PulseAudio from other snaps up to date? Are the paths given there correct?

  3. What is The Best Way™ to make this app work?

By the way, this is just for practice. What I’m really after is making a snap for anki, but their build process is quite a bit more involved, so I thought I’d ease into it a bit…