Accessing pipewire from within snap?

Hello,

I am trying to package an electron application that screen records via pipewire (vesktop discord client) which I have built as a snap package.

It works wonderfully, but when using strict confinement I cannot get the pipewire system screen recording portal to appear? It works on classic confinement.

I’m doing this to try and learn a bit about snap packages so my knowledge is quite poor, but I’m under the impression I’m looking for some kind of pipewire plug for the package which I can’t see existing.

Am I trying to do things the wrong way?

Hello ! @louisallaway .

Can you show the content of your *.yaml file ?

Perhaps you must add some requirements (add those that are relevant) :


# The others requirements

confinement: strict
grade: stable

apps:
  the-app:
    command: # The command 
    plugs:
      - desktop
      - desktop-legacy
      - x11
      - wayland
      - unity7
      - pulseaudio
      - screen-inhibit-control
      - audio-playback
      - audio-record
      - home
      - network
      - gsettings
      - opengl
      - pipewire

      # ......

parts:
  the-app:
    plugin: # define the plugin
    source: # define the source
    stage-packages:
      - pipewire
      - libpipewire-0.2-1
      - wireplumber
      - libspa-0.2-modules
      - gstreamer1.0-pipewire

      # ......

name: vencord
base: core22
version: '0.3.0'
summary: A Discord and Spacebar client implemented directly without Discord API
description: |
  A Discord and Spacebar client implemented directly without Discord API. Made in poland with the Electron framework.

license: MIT
issues: https://github.com/soumyaDghosh/webcord-snap/issues
source-code: https://github.com/SpacingBat3/WebCord
website: https://github.com/soumyaDghosh/webcord-snap
contact: soumyadeepghosh2004@zohomail.in
grade: stable
confinement: strict
compression: lzo
architectures:
  - build-on: amd64

parts:
  launcher:
    source: launcher
    plugin: dump
    override-build: |
      cp launcher $CRAFT_PART_INSTALL/
  webcord:
    plugin: dump
    source: https://github.com/Vencord/Vesktop/releases/download/v$SNAPCRAFT_PROJECT_VERSION/VencordDesktop_$SNAPCRAFT_PROJECT_VERSION_$CRAFT_TARGET_ARCH.deb
    override-build: |
      craftctl default
      rm $CRAFT_PART_INSTALL/opt/Vesktop/chrome-sandbox
      sed -i 's|Icon=vencorddesktop|Icon=usr/share/icons/hicolor/0x0/apps/vencorddesktop.png|' $CRAFT_PART_INSTALL/usr/share/applications/vencorddesktop.desktop

  deps:
    plugin: nil
    stage-packages:
      - libpipewire-0.3-modules
      - libspa-0.2-modules
      - libpipewire-0.3-0
      - libwebrtc-audio-processing1
      - pipewire-bin


plugs:
  shmem:
    interface: shared-memory
    private: true

apps:
  webcord:
    command: launcher
    desktop: usr/share/applications/vencorddesktop.desktop
    autostart: vencorddesktop.desktop
    environment:
      TMPDIR: $XDG_RUNTIME_DIR
      GTK_USE_PORTAL: 1
      PIPEWIRE_CONFIG_NAME: "$SNAP/usr/share/pipewire/pipewire.conf"
      PIPEWIRE_MODULE_DIR: "$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/pipewire-0.3"
      SPA_PLUGIN_DIR: "$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/spa-0.2"
    extensions: [ gnome ]
    plugs:
      - password-manager-service
      - audio-playback
      - audio-record
      - camera
      - network
      - opengl
      - shmem
      - unity7

launcher.sh

#!/bin/bash

if [[ ! -n "$DISABLE_WAYLAND" && -n "$WAYLAND_DISPLAY" ]]; then
  FLAGS="$FLAGS --enable-features=WaylandWindowDecorations,WebRTCPipeWireCapturer --ozone-platform-hint=auto"
    if [ -c /dev/nvidia0 ]; then
      FLAGS="$FLAGS --disable-gpu-sandbox"
    fi
fi


exec "$SNAP/opt/Vesktop/vencorddesktop" --use-tray-icon --no-sandbox --disable-seccomp-filter-sandbox $FLAGS "$@"

This is all you need. Also, please note that you’re doing this by taking permission from the upstream or you yourself is the upstream. Else, they will not like this inititative.

https://github.com/Vencord/Vesktop/issues/102

What I do get was pulling in pipewire as dependent packages within the snap, and then I am guessing using shmem to pipe the host and snap instances together?

Regardless massive shame Vencord won’t allow a community snap version, especially ironic considering what they are doing is basically repackaging discord with a few modifications…

Not like that, the snap has access to the host pipewire, it just needs some libraries do the connection, shmem is needed solely for vencord’s process and not pipewire.

I actually want this to be published, even though they don’t want to. Simply because this is hypocrisy.