Accessing a specific binary in the users system

Hey,

I have a little chat application which I’d like to create a snap of. That application allows pasting a picture. It does so by accessing the xclip binary, piping the data as image/png into stdout and catching stdout. Obviously I can’t access the xclip binary in the snapped version of my application and therefore I get a file not found error. Is there any way to allow this?

Regards
Marcel

If you ship xclip in your snap, your snapped apps can use it directly (it doesn’t need to be exposed as an app).
If you don’t, you can’t “access the xclip binary”; most systems don’t even have xclip.

Meaning I’d have to compile xclip myself?

not necessarily; snapcraft’s stage-packages even makes it easy to not compile it yourself.

Okay, but in my case, xclip is an optional dependency, if it’s there I use it, if not then I just tell the user hey, can't use this feature, you don't have xclip installed or aren't even running on xserver. And I assume that in order to ship xclip i need x11 as an interface which requires x11 on the target? Will I still be able to run my app on a headless machine?

You need the x11 interface, but you don’t need X on the target. You can install a snap that asks for the x11 interface on a device that doesn’t even have the x11 interface (such as Ubuntu Core without a snap to provide x11).

I see, that’s cool. Thanks a lot. Would this be correct?

name: cordless
version: git
summary: Third party discord client
description: |
  A third party discord client for your terminal.
confinement: devmode
base: core18
parts:
  cordless:
    plugin: go
    go-importpath: github.com/Bios-Marcel/cordless
    source: .
    source-type: git
    stage-packages:
      - xclip
    plugs: [x11]
apps:
  cordless:
    command: bin/cordless

That looks correct, but I’m no snapcraft expert.
Once you get it to work though I’d suggest you use a stage stanza to only copy the bits you need, out of what’s pulled in by stage-packages.

FWIW I’d’ve put the plugs stanza on the app, not the part.

Okay, thanks. I’ll test that as soon as I am back at my ubuntu machine :slight_smile:

trying to use kubectl as stage-packages, but throws error like this
The package 'kubectl' was not found.