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?
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 havexclip.
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).
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.