the desktop file is copied by snapcraft and customized e.g. Icon field is changed though the Exec field is not present, this leads to
destkop file didn't specify Exec field
Opening the desktop file with a text editor shows all the fields are present, only Exec missing…
now actually what I want is
Exec=xdg-open http://localhost:8000 which works well if I add this line to the desktop file after snap installation.
Is adding this simple line not possible with snapcraft? was reading everywhere that snapcraft is changing
Exec= to the apps command name though in my case is even missing…
Are there workarounds?
In my case my app is a daemon (with a system tray icon):
I’d like to launch the browser with the
torch.desktop to reach the daemons GUI
Do you have anything else defined in
apps besides daemon? My guess would be it’s removing
Exec because it doesn’t have anything to actually launch. Add another entry in
apps and use that entry in
torch.desktop to launch daemons GUI.
command: xdg-open http://localhost:8000
Exec line needs to reference an app provided by your snap. That app could easily be a single line shell script that runs
exec xdg-open http://localhost:8000.
The reason for the rewriting is to ensure that any code executed by a desktop file provided by your snap is appropriately sandboxed.
Following from @jamesh’s comment this is what your desktop file should look like:
Exec=torch # I changed this line
Failed to generate snap metadata: The specified command ‘xdg-open http://localhost:8000’ defined in the app ‘torch’ is not executable.
if I use a shell script and add it to the snapcraft part install:
chmod +x ./open_browser.sh
cp ./open_browser.sh $SNAPCRAFT_PART_INSTALL/.
chmod +x $SNAPCRAFT_PART_INSTALL/open_browser.sh
mv $SNAPCRAFT_PART_INSTALL/open_browser.sh $SNAPCRAFT_PART_INSTALL/open_browser
chmod +x $SNAPCRAFT_PART_INSTALL/open_browser
ls -al $SNAPCRAFT_PART_INSTALL/
drwxr-xr-x 5 root root 4096 Sep 17 18:41 .
drwxr-xr-x 6 root root 4096 Sep 17 18:41 ..
drwxr-xr-x 2 root root 4096 Sep 17 18:41 bin
-rwxr-xr-x 1 root root 160 Sep 17 18:41 open_browser
drwxr-xr-x 3 root root 4096 Sep 17 18:41 opt
drwxr-xr-x 3 root root 4096 Sep 17 18:41 usr
Failed to generate snap metadata: The specified command 'open_browser' defined in the app 'torch' is not executable.
ok, it seems like my part and my app have to have the same name…
not only missing a way to add xdg-open to my snap
if I do:
snap run --shell torch -c "xdg-open http://localhost:8000"
Error org.freedesktop.DBus.Error.ServiceUnknown: The name com.canonical.SafeLauncher was not provided by any .service files
If I do the same command above with another app that I created that have the same plugs but also
extensions: [gnome-3-28] then it works.
there there a way to use
xdg-open with cli apps that do not have any desktop extensions?