Executing a script inside snap package. Is this possible?

Eloy García (PC Actual) eloy.garcia.pca at gmail.com
Sun Apr 16 21:13:45 UTC 2017


Hello everybody.

I develop a graphical java-based application which is published in the
Ubuntu Store as a snap package (sctrict confinment) called
wallpaperdownloader to download, manage and set desktop wallpapers.

I'm developing version 2.7 which will bring KDE support, but for this I
need to execute a shell script from Java. In classic confinement and
natively, this script is executed without problems. I use this code to do
it:

process = Runtime.getRuntime().exec("/bin/sh " + WDUtilities.getAppPath() +
WDUtilities.URL_SLASH + WDUtilities.PLASMA_SCRIPT + " " +  wallpaperPath);

As you can see, I use /bin/sh command to run the script. This is the
content of the script:

#!/bin/bash

# Changing wallpaper
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript
"var allDesktops = desktops();print (allDesktops);for
(i=0;i<allDesktops.length;i++) {d =
allDesktops[i];d.wallpaperPlugin = 'org.kde.image';d.currentConfigGroup =
Array('Wallpaper', 'org.kde.image', 'General');d.writeConfig('Image',
'file://"$1"')}"

This command changes the current wallpaper for version 5.8 or higher in
Plasma.

When this part is executed within the snap package (strict confinement),
nothing happens. I have tried to include bash and dash pacakges as
stage-packages but it doesn work. Is this something that can be achieved
using the snap package system?

Thank you very much!

Best,

Eloy

-- 
Eloy García Almadén



More information about the Snapcraft mailing list