Re: Executing a script inside snap package. Is this possible?

2017-04-16 Thread PC Actual
Thank you very much for your answer Michel. I hope somebody from snapd or
security team can help too :)

El 17 abr. 2017 3:07 a. m., "Michael Hall" <mhall...@ubuntu.com> escribió:

> Running a script inside of your snap with either /bin/sh or /bin/bash
> should be no problem at all. However looking at your script I see that
> you're making dbus calls out to the Plasma Shell, and that *will* be
> blocked by the strict confinement.
>
> You will probably need to get a snapd interface created to support this
> dbus interface, or maybe you can use the generic 'dbus' interface and
> specify this service, which would have to be manuall connected. I'm
> hoping someone from the snapd or security teams can chime in and be more
> specific about what your options are here.
>
> Michael Hall
> mhall...@ubuntu.com
>
> On 04/16/2017 05:13 PM, Eloy García (PC Actual) wrote:
> > 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
> >
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Executing a script inside snap package. Is this possible?

2017-04-16 Thread PC Actual
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

Re: Moving from strict to classic confinement

2017-03-28 Thread PC Actual
Hi Renato,

2017-03-27 15:31 GMT+02:00 Renato Filho <renato.fi...@canonical.com>:

> 2017-03-27 4:22 GMT-03:00 Eloy García (PC Actual) <
> eloy.garcia@gmail.com>:
> > Hello everybody.
> >
> > I currently have a snap package published on the store. It is called
> > wallpaperdownloader and it is a Java-based application. So far, it has
> been
> > packaged using the strict confinement. The application basically
> downloads
> > wallpapers from the Internet and sets the wallpaper when the user
> requests
> > it. Because there are a lot of desktop environments, I have ended up
> using
> > a lot of Linux commands from the java application in order to achieve
> these
> > goals. For some DE there is no problem at all: for example, using
> gsettings
> > interface, GNOME Shell and Unity change the background flawlessly. MATE
> is
> > working properly too (I had to include mate-desktop-common as stage
> > package) but XFCE and KDE... no way. In addition, some of the most simple
> > features (open a file explorer for example) don't work.
>
> I am not sure what exactly the problem that you have to change KDE
> wallpapers but it can be related with the fact that you are using
> "desktop-gtk3", because this only prepare the environment for gtk
> apps. Some environment vars will be missing for Qt apps.
>
>
My main problem is that, first, I need to know Plasma version. in the
native installation, I execute, form Java, "plasmashell --version" command,
which gives me this version. This command in the snap confinement doesn't
exit.


> The options that you have are:
>
> 1 - create a wrapper file and export the vars by yourself.
> 2 - Use "ubuntu-app-platform"  that contains libraries and a launcher
> compatible with most gtk and qt apps.
>
>
Do you think that using ubuntu-app-platform part could have, for example,
the command I described above?. In order to change the wallpaper I have to
invoke qdbus. Same problem here. Using this part will the command be
available?


> I hope this help
>
>
Thank you very much!!! :)


> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>



-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Moving from strict to classic confinement

2017-03-28 Thread PC Actual
2017-03-27 15:14 GMT+02:00 Sergio Schvezov <sergio.schve...@canonical.com>:

> On Mon, 27 Mar 2017 09:22:03 +0200, Eloy García (PC Actual) wrote:
> > Hello everybody.
> >
> > I currently have a snap package published on the store. It is called
> > wallpaperdownloader and it is a Java-based application. So far, it has
> been
> > packaged using the strict confinement. The application basically
> downloads
> > wallpapers from the Internet and sets the wallpaper when the user
> requests
> > it. Because there are a lot of desktop environments, I have ended up
> using
> > a lot of Linux commands from the java application in order to achieve
> these
> > goals. For some DE there is no problem at all: for example, using
> gsettings
> > interface, GNOME Shell and Unity change the background flawlessly. MATE
> is
> > working properly too (I had to include mate-desktop-common as stage
> > package) but XFCE and KDE... no way. In addition, some of the most simple
> > features (open a file explorer for example) don't work.
> >
> > I have been testing the classic confinement and all these features work!
> In
> > addition, I don't need to include some dependencies like desktop-gtk3 or
> > use a shell script wrapper to launch the application. Then, I'm
> considering
> > to move my snap package from stric to classic confinement but i don't
> know
> > the possible implications:
> >
> > 1.- Are the interfaces still needed when using classic confinement?
>
> No, they are not.
>
> > 2.- From the user point of view: if wallpaperdownloader is already
> > installed and I change the confinement, when snapd upgrades it, will it
> > work flawlessly? I mean, the upgrade process will be automatic or it will
> > require manual intervention from the user?
>
> They will need updating. HOME in strict confinement points to the
> segregated data stores, in classic it is the traditional home.
>
> > 3.- As I see classic confinement, it is a feature to make snap packages
> > more easily but they only will work on a "classic" Ubuntu system. If
> Ubuntu
> > is finally migrated to a Snappy system, I guess classic confinement won't
> > work and all these packages should be migrated to strict confinement
> again,
> > am I right?
>
> This is correct, a pure snappy based system is not a classic system so
> classic confinement does not apply.
>
> > Thank you all for your time :)
>
> A few more considerations:
>
> - I would stick to strict having gotten this far and just work on
> unblocking yourself with interfaces or other means.
>

Ok Sergio, you convinced me :) It is true. i have had to deal with a lot of
problems until getting an almost totally functional snap for my
application, and if the user should have to upgrade manually the snap...
I'll stick on strict mode! :D


> - strict confinment means you have a stable base (core), while classic
> means you will have an unstable one (well, not unstable, just different
> depending on the system where the snap is installed), which means you will
> have a different set of bugs to deal with depending on the base classic
> system where the snap is installed.
> - you shouldn't rely on libraries on classic systems, not all of them with
> have gtk3 nor will all of them be ABI compatible with the glibc stuff your
> snap uses (this might be a different story with java).
>

The "problem" with wallpaperdownloader is that I try to be fully compatible
with the main Desktop Environments in Linux (at the moment, the application
works fine with Unity 7, Gnome Shell. Mate, XFCE and KDE (not yet for
vesion 2.6 but I'm implementing it for version 2.7)). In order to tell the
DE to change the wallpaper I have to use some tools and commands which are
available only for this DE and snap packaging is a challenge for me in
order to take into account all this environments if I cannot "rely on" the
host DE itself (I don't know if I'm expressing myself clearly, sorry for
that)


> - There is a missing feature in snapd/snap-confine to restrict the library
> paths the classic confined snap can see, so you need to make sure this is
> the case for you. This can be mitigated in snapcraft if you build all
> runnables from parts (in your case the jre which I bet wouldn't be easy).
> - I am going to be talking again a bout classic confined snaps in one of
> the upcoming Ubuntu Testing days, so if interested, keep an eye on that ;-)
>
>
I'll keep an eye on, for sure! Thank you very much!!

Best,

Eloy

-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Moving from strict to classic confinement

2017-03-27 Thread PC Actual
Hi Alistair!

Thanks for the tip, but this is not a problem anymore. Yep, I used "the
bridge" provided by Ubuntu Core for xdg-open and it works if the user
installs snapd-xdg-open :)

Best,

Eloy

2017-03-27 9:32 GMT+02:00 Alistair Grant <akgrant0...@gmail.com>:

> Hi Eloy,
>
> Your readme mentions problems with xdg-open.  Take a look at:
>
> https://github.com/snapcore/snapd-xdg-open
>
> which may help.  Note that the host has to have snapd-xdg-open installed.
>
> Cheers,
> Alistair
>
> On 27 March 2017 at 09:22, Eloy García (PC Actual)
> <eloy.garcia@gmail.com> wrote:
> > Hello everybody.
> >
> > I currently have a snap package published on the store. It is called
> > wallpaperdownloader and it is a Java-based application. So far, it has
> been
> > packaged using the strict confinement. The application basically
> downloads
> > wallpapers from the Internet and sets the wallpaper when the user
> requests
> > it. Because there are a lot of desktop environments, I have ended up
> using
> > a lot of Linux commands from the java application in order to achieve
> these
> > goals. For some DE there is no problem at all: for example, using
> gsettings
> > interface, GNOME Shell and Unity change the background flawlessly. MATE
> is
> > working properly too (I had to include mate-desktop-common as stage
> > package) but XFCE and KDE... no way. In addition, some of the most simple
> > features (open a file explorer for example) don't work.
> >
> > I have been testing the classic confinement and all these features work!
> In
> > addition, I don't need to include some dependencies like desktop-gtk3 or
> > use a shell script wrapper to launch the application. Then, I'm
> considering
> > to move my snap package from stric to classic confinement but i don't
> know
> > the possible implications:
> >
> > 1.- Are the interfaces still needed when using classic confinement?
> > 2.- From the user point of view: if wallpaperdownloader is already
> > installed and I change the confinement, when snapd upgrades it, will it
> > work flawlessly? I mean, the upgrade process will be automatic or it will
> > require manual intervention from the user?
> > 3.- As I see classic confinement, it is a feature to make snap packages
> > more easily but they only will work on a "classic" Ubuntu system. If
> Ubuntu
> > is finally migrated to a Snappy system, I guess classic confinement won't
> > work and all these packages should be migrated to strict confinement
> again,
> > am I right?
> >
> > Thank you all for your time :)
> >
> > Best,
> >
> > Eloy
> > --
> > Eloy García Almadén
> > --
> > Snapcraft mailing list
> > Snapcraft@lists.snapcraft.io
> > Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>



-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Snaps to invoke external processes

2016-11-21 Thread PC Actual
Thanks for the explanation Didier. :)

I'll try to install that package and check if it works. However, I guess
this package is only available for Ubuntu users right? Does anybody know if
it will be available on other distributions? It makes sense to me that if
snapd is a cross-distribution package, snapd-xdg-open should be available
too.

Best,

Eloy

2016-11-21 10:22 GMT+01:00 Didier Roche <didro...@ubuntu.com>:

> Le 21/11/2016 à 09:30, Eloy García (PC Actual) a écrit :
>
> Hi Didier.
>
> My snap package (wallpaperdownloader) invokes xdg-open internally but it
> isn't working yet. Should I use a specific interface to accomplish that?
> This is the snapcraft.yml
>
>
> Hey Eloy,
>
> You need to have snapd-xdg-open package installed on the desktop. IIRC,
> the goal was to seed it by default or have snapd recommending it. CCing mvo
> on that who also responsible for the package on ubuntu if there is any
> reason this isn't the case yet.
>
> Ensure you are then using xdg-open from /usr/local/bin/.
>
> I konw this is working with the unity7 interface (I don't remember if the
> x11 one is succifient, but it should, if not, it's a bug).
> Cheers
> Didier
>
>
> name: wallpaperdownloader
> version: "2.3"
> summary: Download, manage and change your favorite wallpapers from the 
> Internet
> description: WallpaperDownloader is a simple GUI Java based application for 
> downloading, managing and changing wallpapers from the Internet
> grade: stable
> confinement: strict
>
> apps:
>   wallpaperdownloader:
> command: wallpaperdownloader.sh
> plugs: [x11, network-bind, home, gsettings]
>
> parts:
>   # Pulls the code from the original source (master branch)
>   # desktop/gtk3 is a snapcraft part (snapcraft-desktop-helpers) from the 
> Wiki: https://wiki.ubuntu.com/snapcraft/parts
>   # It enables desktop integration and gsettings manipulation from the 
> confined application
>   # It is necessary to use gsettings interface (see above) in order to have a 
> fully functional
>   # desktop/gtk3 part
>   # Github repository for snapcraft-desktop-helpers: 
> https://github.com/ubuntu/snapcraft-desktop-helpers
>   wallpaperdownloader:
> source: https://bitbucket.org/eloy_garcia_pca/wallpaperdownloader.git
> plugin: maven
> stage-packages:
>   # mate-desktop-common is necessary to have MATE gsettings schemas 
> available for the application
>   - mate-desktop-common
> after: [desktop-gtk3]
>
>   # It will copy wallpaperdownloader script into /bin/
>   # This script contains all the commands needed (sets env variables, 
> launches the jar file...) to
>   # execute the application
>   exec:
> plugin: dump
> source: scripts
>
>
> Thanks!!!
>
> Best,
>
> Eloy
>
> 2016-11-21 8:08 GMT+01:00 Didier Roche <didro...@ubuntu.com>:
>
>> Le 21/11/2016 à 04:26, Spencer a écrit :
>> > It's been a few weeks now, but last I heard, the snapcraft team was or
>> did a sprint to address current limitations snaps have regarding the
>> invocation of external processes.  Specifically, it would be nice to launch
>> the user's default browser with a URL, or let a snap invoke another
>> instance of itself.  What's the status on this?
>> >
>> Hey Spencer,
>>
>> Default browser should works for some months already if your application
>> (or toolkit, like Qt does) invoke the xdg-open to open the url. This is
>> then transmitted via dbus to an external process on your classic system
>> which then issues the real xdg-open command.
>> For the others, there are been indeed multiple discussions on this at
>> multiple places (here, on the bug report…), but no action or firm
>> decision. I'm CCing Gustavo as he was the one against a more generic
>> intermediate solutions.
>>
>> Cheers,
>> Didier
>>
>>
>> --
>> Snapcraft mailing list
>> Snapcraft@lists.snapcraft.io
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailm
>> an/listinfo/snapcraft
>>
>
>
>
> --
> Eloy García Almadén
>
>
>
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>
>


-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Snaps to invoke external processes

2016-11-21 Thread PC Actual
Hi Didier.

My snap package (wallpaperdownloader) invokes xdg-open internally but it
isn't working yet. Should I use a specific interface to accomplish that?
This is the snapcraft.yml

name: wallpaperdownloader
version: "2.3"
summary: Download, manage and change your favorite wallpapers from the Internet
description: WallpaperDownloader is a simple GUI Java based
application for downloading, managing and changing wallpapers from the
Internet
grade: stable
confinement: strict

apps:
  wallpaperdownloader:
command: wallpaperdownloader.sh
plugs: [x11, network-bind, home, gsettings]

parts:
  # Pulls the code from the original source (master branch)
  # desktop/gtk3 is a snapcraft part (snapcraft-desktop-helpers) from
the Wiki: https://wiki.ubuntu.com/snapcraft/parts
  # It enables desktop integration and gsettings manipulation from the
confined application
  # It is necessary to use gsettings interface (see above) in order to
have a fully functional
  # desktop/gtk3 part
  # Github repository for snapcraft-desktop-helpers:
https://github.com/ubuntu/snapcraft-desktop-helpers
  wallpaperdownloader:
source: https://bitbucket.org/eloy_garcia_pca/wallpaperdownloader.git
plugin: maven
stage-packages:
  # mate-desktop-common is necessary to have MATE gsettings
schemas available for the application
  - mate-desktop-common
after: [desktop-gtk3]

  # It will copy wallpaperdownloader script into /bin/
  # This script contains all the commands needed (sets env variables,
launches the jar file...) to
  # execute the application
  exec:
plugin: dump
source: scripts


Thanks!!!

Best,

Eloy

2016-11-21 8:08 GMT+01:00 Didier Roche :

> Le 21/11/2016 à 04:26, Spencer a écrit :
> > It's been a few weeks now, but last I heard, the snapcraft team was or
> did a sprint to address current limitations snaps have regarding the
> invocation of external processes.  Specifically, it would be nice to launch
> the user's default browser with a URL, or let a snap invoke another
> instance of itself.  What's the status on this?
> >
> Hey Spencer,
>
> Default browser should works for some months already if your application
> (or toolkit, like Qt does) invoke the xdg-open to open the url. This is
> then transmitted via dbus to an external process on your classic system
> which then issues the real xdg-open command.
> For the others, there are been indeed multiple discussions on this at
> multiple places (here, on the bug report…), but no action or firm
> decision. I'm CCing Gustavo as he was the one against a more generic
> intermediate solutions.
>
> Cheers,
> Didier
>
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>



-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: snap integration with XFCE

2016-11-01 Thread PC Actual
Hi Didier, hi all.

I've been trying to accomplish this mission but I miss something (my bet is
that I need an interface similar to gsettings but it doesn't exist
something like this).

1.- I have successfully created a symlink from
/home/$USER/.config/xfce4/xfconf/xfce-perchannel-xml inside the snap
directory and all the XML files in which the configuration is stored are
accessible for the application.

2.- I have defined, as stage package, xfconf, the tool to write
configurations directly into those XML files.

3.- But when I execute ' xfconf-query --channel xfce4-desktop --property
/backdrop/screen0/monitor0/workspace0/last-image --set wallpaper.jpg'
inside my application, I still receive 'Property
"/backdrop/screen0/monitor0/workspace0/last-image" does not exist on
channel "xfce4-desktop". If a new property should be created, use the
--create option.' and xfce-destop.xml (the XML which has the configuration
for the background wallpaper) is not modified at all.

Maybe is needed an interface similar to gsettings? If this is the case, can
I program something like that?

Thank you very much! :)

Best,

Eloy

2016-10-24 11:08 GMT+02:00 Didier Roche <didro...@ubuntu.com>:

> Le 24/10/2016 à 10:58, Eloy García (PC Actual) a écrit :
> > Hi Didier!
> >
> > Thanks as always for your answer and feedback :) I suspected it and I
> > was taking a look to desktop launcher source code on github, but I
> > didn't have time to test it. One question: Can I create the symblink
> > when the snap application is executed (after installation) via the
> > script that i use to wrap up the launching process or will I have
> > problems to do that because of the confinement?
>
> No worry :)
>
> As long as your snap has the right plug to access the initial file, this
> isn't an issue (and exactly what I'm doing in the desktop launcher for
> dconf/gsettings: creating symlink on first launch or after each snap
> upgrade if the symlink isn't present).
> You can see such an example in
> https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/glib-only/
> launcher-specific#L37
> for instance.
>
> (But yeah, it relies on /home/$USER/ and should probably find a better
> way to get user's real home directory. I can't use $HOME as it's
> redirected to SNAP_USER_DATA in some cases)
>
>
> >
> > Best,
> >
> > Eloy
> >
> > 2016-10-24 10:14 GMT+02:00 Didier Roche <didro...@ubuntu.com
> > <mailto:didro...@ubuntu.com>>:
> >
> > Le 06/10/2016 à 21:34, Eloy García (PC Actual) a écrit :
> >> Hi all.
> >>
> >> I develop a java-based application to download and manage
> >> wallpapers from the Internet (wallpaperdownloader)
> >> (https://bitbucket.org/eloy_garcia_pca/wallpaperdownloader/overview
> <https://bitbucket.org/eloy_garcia_pca/wallpaperdownloader/overview>).
> >> The applications is in the store but now I'm trying to integrate
> >> XFCE desktop too. I mean, now you can set any wallpaper downloaded
> >> directly from the GUI and it is working fine for GNOME 3, Unity
> >> and MATE. All three of them use gsettings interface and
> >> desktop-gtk3 wrapper part as you can see in the snapcraft.yaml:
> >>
> >> name: wallpaperdownloader
> >> version: "2.2"
> >> summary: Download and manage your favorite wallpapers from the
> Internet
> >> description: WallpaperDownloader is a simple GUI Java based
> application for
> >> downloading and managing wallpapers from the Internet
> >> grade: stable
> >> confinement: strict
> >>
> >> apps:
> >>   wallpaperdownloader:
> >> command: wallpaperdownloader.sh
> >> plugs: [x11, network-bind, home, gsettings]
> >>
> >> parts:
> >>   # Pulls the code from the original source (master branch)
> >>   # desktop/gtk3 is a snapcraft part (snapcraft-desktop-helpers)
> >> from the Wiki: https://wiki.ubuntu.com/snapcraft/parts
> >> <https://wiki.ubuntu.com/snapcraft/parts>
> >>   # It enables desktop integration and gsettings manipulation from
> >> the confined application
> >>   # It is necessary to use gsettings interface (see above) in order
> >> to have a fully functional
> >>   # desktop/gtk3 part
> >>   # Github repository for snapcraft-desktop-helpers:
> >> https://github.com/ubuntu/snapcraft-desktop-helpers
> >> <https://github.com/ubuntu/snapcraft-desktop-helpers>
> >>   wallpaperdownloader:
> >

Re: Using xdg-open from snap

2016-09-21 Thread PC Actual
Hi all.

I have the same problem in my snap java-based application. I use xdg-open
command to launch the default browser so, it would be great a solution :)

Best,

Eloy

2016-09-20 15:46 GMT+02:00 Spencer Parkin :

> This is related to a question I had as well.  I have a program that uses
> wxLaunchDefaultBrowser which, looking at its implementation, tries to make
> the system call "exec()" to launch the default browser with a URL.
>
> If snap programs are not allowed to start other processes, that's fine;
> but if enough people need to launch the default browser with a URL, then
> I'm sure a secure solution just for this could somehow be implemented for
> snaps.
>
> I gather that one design goal of snaps, however, is the ability for people
> to write programs for any environment, but also have them work as snaps so
> that the programmer doesn't have to write snap-specific code, or make
> snap-specific considerations in their code.  In other words, your code
> should be "none-the-wiser" that it is running in the confined area.
>
> So with that in mind, I'm not sure how to solve the problem.  Any secure
> API exposed to snap applications already breaks the above design goal.
>
> Of course, it's not unreasonable for my program to have "#ifdef WIN32" or
> "#ifdef UNIX", and in the latter case, I may be looking to utilize
> something in a standard unix environment which, I believe, is synthesized
> in Unbuntu Core.  That's where I believe the snap environment can intercept
> what an application is doing and provide a secure solution, and this may be
> the "xdg-open" thing Otfried was talking about.
>
>
> On Mon, Sep 19, 2016 at 2:37 AM, Otfried Cheong 
> wrote:
>
>> Hello,
>>
>> my app has a manual in html.  I normally show this using "xdg-open
>> ", but from the snap this results in "xdg-open: Permission denied",
>> leaving this log:
>>
>> [21249.231634] audit: type=1400 audit(1474273861.873:383):
>> apparmor="DENIED" operation="exec" profile="snap.ipe.sh"
>> name="/usr/local/bin/xdg-open" pid=9551 comm="sh" requested_mask="x"
>> denied_mask="x" fsuid=1000 ouid=0
>>
>> According to
>> https://lists.ubuntu.com/archives/snapcraft/2016-September/001048.html
>> this should work.
>> I did refresh ubuntu-core from the beta channel and currently have
>> revision 636 of ubuntu-core.
>>
>>
>> Slightly related:  If I understand
>> https://lists.ubuntu.com/archives/snapcraft/2016-September/001118.html
>> correctly, the host filesystem should be exposed to the snap as
>> /var/lib/snapd/hostfs in devmode?It isn't on my system.
>>
>> Cheers,
>>  Otfried
>>
>>
>> --
>> Snapcraft mailing list
>> Snapcraft@lists.snapcraft.io
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailm
>> an/listinfo/snapcraft
>>
>
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>
>


-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Access to other commands

2016-09-08 Thread PC Actual
Hi all.

I currently have several problems with my snap package for
wallpaperdownloader application, a java-based piece of software that
downloads wallpapers from the Internet, and maybe this is the solution for
some of them.
In this application, I execute some Linux command tools such as xdg-open
and gsettings. They work flawlessly within a "native" environment, but when
I try to execute them inside the snap package, they simply don't work.

Gustavo, when you suggest to use the line: bus-send --print-reply --session
--dest=com.canonical.SafeLauncher / com.canonical.SafeLauncher.OpenURL
string:"$1"
could you give an example of that? I mean, if I want to, for example, open
a browser using "xdg-open https://www.google.com; executing this command
from my Java code, what would be the line I should use instead?. This
implies to modify my java code too and I had to do the distinction between
the application executed in a native environment and in a snap confinement.
This wouldn't be the desired way of packaging the app. Would be possible to
use some kind of interface to have access to the "native" command line
tools installed in the system? This way, source code would be agnostic (I
mean, I didn't have to tweak the application depending on the environment
executed) and it would be only a matter of snapcraft.yaml configuration.

Thanks in advance :)

Best,

Eloy

2016-09-08 4:11 GMT+02:00 Gustavo Niemeyer :

>
>
> On Wed, Sep 7, 2016 at 10:31 PM, Mark Shuttleworth 
> wrote:
>
>> On 07/09/16 12:32, Matthew Williams wrote:
>> > I have a few applications I'm looking to snap, but quite a lot of them
>> > shell out to other commands at some point and it's not always
>> > practical to include these with my snap, one concrete example is
>> > shelling out to /usr/bin/sensible-browser.
>>
>
> We have something slightly better than this. Any snap can call xdg-open
> $url and have that URL being sent to a safe launcher over dbus.
>
> This is the exact line:
>
> bus-send --print-reply --session --dest=com.canonical.SafeLauncher /
> com.canonical.SafeLauncher.OpenURL string:"$1"
>
> Because this is always safe to do and offered over a common mechanism, we
> don't need an interface to mediate it. If something is listening, a browser
> is fired.
>
> We need to make sensible-browser call the same so applications just work.
>
>
> gustavo @ http://niemeyer.net
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>
>


-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: No such file or directory when try to execute gsettings

2016-09-07 Thread PC Actual
Hi Sebastien!

First of all, thank you very much for your suggestions :)

I get your point and I think this is the real problem. I guess gsettings
command line tool from the snap is storing the correct key/value inside the
snap, but the "native" dconf database is not getting the new value, because
the change wasn't made using "native" gsettings command line tool. I have
tried to search dconf database within snap confinement, but I couldn't find
it. Where should I search for it to see if the new value for the wallpaper
was set there?

P.S.: I've been searching within the tree which is in
/snap/wallpaperdownloader/current with no luck.

Thank you very much again :D

2016-09-06 11:42 GMT+02:00 Sebastien Bacher <seb...@ubuntu.com>:

> Le 30/08/2016 à 10:15, Eloy García (PC Actual) a écrit :
> > Thanks for your answer, but I forgot to say I tried gsettings and
> > unity7 interfaces with no success. Nevertheless, I only put those
> > interfaces in snapcraft.yml, but I didn't do anyting else
> > (configurations, tweaks...). Adding more information, this is the
> > script executed when wallpaperdownloader is launched. Maybe it is here
> > where I should add some mappings to the "native" environment?
>
>
> Hey again,
>
> Did you figure it out? The gsettings command talk over dbus to the
> service which is in the user session, so the key should be written in
> your user db, the confined code in the snap doesn't get back the value
> since dconf does that by mapping a file from the user directory so it
> might mean your frontend might not get the new value of the key. Can you
> check from the outside the value of the key?
>
> If you use the shared desktop launcher it includes an hack to symlink
> the snap dconf db to the real one which should make reading work as well
>
> Cheers,
>
> Sebastien Bacher
>
>


-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: No such file or directory when try to execute gsettings

2016-08-30 Thread PC Actual
Hi all again.

As Sebastian Bacher suggested, I included gsettings binary within my snap
package. This is the snapcraft.yaml file:

name: wallpaperdownloader
version: "2.2"
summary: Download and manage your favorite wallpapers from the Internet
description: WallpaperDownloader is a simple GUI Java based application for
downloading and managing wallpapers from the Internet
confinement: strict

apps:
  wallpaperdownloader:
command: wallpaperdownloader.sh
plugs: [x11, network-bind, home]

parts:
  # Pulls the code from the original source (master branch)
  wallpaperdownloader:
plugin: maven
source: .
stage-packages:
  - libglib2.0-bin

  # It will copy wallpaperdownloader script into /bin/
  # This script contains all the commands needed (sets env variables,
launches the jar file...) to
  # execute the application
  exec:
plugin: copy
files:
  wallpaperdownloader.sh: bin/wallpaperdownloader.sh


-

Including libglib2.0-bin as stage-package, the application doesn't complain
anymore about "No such file or directoy" because it finds gsettings binary
on stage/usr/bin. Nevertheless, nothing happens when command line
"gsettings set org.gnome.desktop.background picture-uri
file://blablabla.jpg" is executed within the java code. I don't know how to
"link" this command inside the snap with the native "command" and
configuration files outside. The execution of this command should affect to
the native environment and not the snap confinement created I guess, in
order to change the current wallpaper in GNOME 3 or Unity.

Any ideas or suggestions? Thank you very much for your time and effort :)

Best,
Eloy




2016-08-26 11:00 GMT+02:00 Eloy García (PC Actual) <
eloy.garcia@gmail.com>:

> Thank you very much for your quick answer. I want to implement this for
> other desktop environments, so I guess I have to include every binary I
> want to invoke, right?
>
> I'll give it a try. Thanks again!
>
> El 26 ago. 2016 10:26 a. m., "Sebastien Bacher" <seb...@ubuntu.com>
> escribió:
>
>> Le 26/08/2016 à 07:23, Eloy García (PC Actual) a écrit :
>> > I have tried gsettings and Unity7 interfaces with no luck. i guess is
>> > more a question of executing a program outside the confinment. How
>> > could I do that? Thank you very much!
>>
>> Hey,
>>
>> Using the system command is not allowed but you can include it in your
>> snap and it should work (either copy the binary or stage-packages the deb)
>>
>> Cheers,
>>
>> Sebastien Bacher
>>
>>
>> --
>> Snapcraft mailing list
>> Snapcraft@lists.snapcraft.io
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailm
>> an/listinfo/snapcraft
>>
>


-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: No such file or directory when try to execute gsettings

2016-08-26 Thread PC Actual
Thank you very much for your quick answer. I want to implement this for
other desktop environments, so I guess I have to include every binary I
want to invoke, right?

I'll give it a try. Thanks again!

El 26 ago. 2016 10:26 a. m., "Sebastien Bacher" <seb...@ubuntu.com>
escribió:

> Le 26/08/2016 à 07:23, Eloy García (PC Actual) a écrit :
> > I have tried gsettings and Unity7 interfaces with no luck. i guess is
> > more a question of executing a program outside the confinment. How
> > could I do that? Thank you very much!
>
> Hey,
>
> Using the system command is not allowed but you can include it in your
> snap and it should work (either copy the binary or stage-packages the deb)
>
> Cheers,
>
> Sebastien Bacher
>
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


No such file or directory when try to execute gsettings

2016-08-25 Thread PC Actual
Hello everybody.

I am developing a java-based application that downloads and changes the
desktop wallpaper. Depends on the desktop environment, it has to execute a
"native" program to do this job. For instance, in Unity executes "gsettings
set org.gnome.desktop.background picture-uri
file:///home/serrano/Pictures/y.jpg" command line, but gsettings is not
found under confinment, throwing this error: Cannot run program
"gsettings": error=2, No such file or directory.

I have tried gsettings and Unity7 interfaces with no luck. i guess is more
a question of executing a program outside the confinment. How could I do
that? Thank you very much!

Best,

Eloy

-- 
Eloy García Almadén
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: .desktop files for app-in-snap

2016-08-09 Thread PC Actual
Hi again Vasilisc.

Now I see the problem. If you pin the application executed from the
terminal, the Operating System creates its own standard launcher and
"bypasses" the init script you have defined within the snap package.
Instead, if you want to pin a snap application, you have to use the
launcher which was created in the dashboard (it has the icon you defined
within the snap package).

I think it is a limitation that you cannot handle, but please, if anyone
knows how to deal with it... :)

Best,

Eloy

2016-08-09 9:23 GMT+02:00 Vasilisc <vasilisc...@gmail.com>:

> 09.08.2016 10:05, Eloy García (PC Actual) пишет:
>
>> Hi again!
>> You don't need to have java installed on your system. This is the
>> "magic" of a snap package, that you can include anything your
>> application needs to run properly. I use maven plugin for my
>> application, so openjdk 8 is installed within the snap package.
>>
>
> Please, create the virtual machine with Ubuntu 16.04.
> Install - sudo snap install wallpaperdownloader
>
> run wallpaperdownloader in Terminal and pin app
>
> close wallpaperdownloader and launch app from Unity Launcher.
> something happening? none!
>
> "Exec=java" try execute Java in the host, but Java is not installed by
> default.
>
> Your Java in snap placed - $SNAP/usr/lib/jvm/default-java/bin/java
> Sorry for my english. really only I see a problem?
>
>
>> El 9 ago. 2016 7:31 a. m., "Vasilisc" <vasilisc...@gmail.com
>> <mailto:vasilisc...@gmail.com>> escribió:
>>
>> 09.08.2016 07:52, Vasilisc пишет:
>>
>> 08.08.2016 11:13, Eloy García (PC Actual) пишет:
>>
>> Hi! You can take a loot at snappy playpen github repository.
>> There is an
>> application (wallpaperdownloader) that it is java-based and
>> it has a
>> desktop icon working fine. This is the URL:
>>
>> https://github.com/ubuntu/snappy-playpen
>> <https://github.com/ubuntu/snappy-playpen>
>>
>> Best wishes!
>>
>> El 8 ago. 2016 9:46 a. m., "Didier Roche"
>> <didro...@ubuntu.com <mailto:didro...@ubuntu.com>
>> <mailto:didro...@ubuntu.com <mailto:didro...@ubuntu.com>>>
>> escribió:
>>
>> >
>>
>> Le 08/08/2016 à 08:47, Vasilisc a écrit :
>> > 08.08.2016 08:50, Didier Roche пишет:
>> >> Le 06/08/2016 à 09:47, Vasilisc a écrit :
>> >>>> Please help me. If I launch the program in the
>> Terminal - well
>> done,
>> >>>> but
>> >>>> I can't start program from Unity Launcher.
>> >>>>
>> >>>> I tried to change parameter Exec in
>> >>>> ~/.local/share/applications/app.desktop
>> >>>> Exec=app-name
>> >>>> Exec=snap-name.app-name
>> >>>> Exec=$SNAP/usr/bin/start-script.sh
>> >>>> Exec=$snap.$app
>> (http://snapcraft.io/docs/snaps/structure
>> <http://snapcraft.io/docs/snaps/structure>)
>>
>> >>>>
>> >>>> and studied case
>>
>> https://github.com/ubuntu/snap
>> py-playpen/blob/master/vlc/setup/gui/vlc.desktop
>> <https://github.com/ubuntu/sna
>> ppy-playpen/blob/master/vlc/setup/gui/vlc.desktop>
>>
>> <https://github.com/ubuntu/snappy-playpen/blob/master/vlc/
>> setup/gui/vlc.desktop
>> <https://github.com/ubuntu/snappy-playpen/blob/master/vlc/
>> setup/gui/vlc.desktop>>
>>
>> >>>>
>> >>>>
>> >>>>
>> >>>> but it didn't help.
>> >>>>
>> >>> suspect lines
>> >>> Aug  6 10:20:35 vb gnome-session[2377]:
>> (gnome-software:2582):
>> >>> As-WARNING **: failed to rescan: Failed to parse
>> >>>
>>
>> /home/vasilisc/.local/share/applications/org-langua

Re: .desktop files for app-in-snap

2016-08-08 Thread PC Actual
Hi! You can take a loot at snappy playpen github repository. There is an
application (wallpaperdownloader) that it is java-based and it has a
desktop icon working fine. This is the URL:

https://github.com/ubuntu/snappy-playpen

Best wishes!

El 8 ago. 2016 9:46 a. m., "Didier Roche"  escribió:

>

> Le 08/08/2016 à 08:47, Vasilisc a écrit :
> > 08.08.2016 08:50, Didier Roche пишет:
> >> Le 06/08/2016 à 09:47, Vasilisc a écrit :
>  Please help me. If I launch the program in the Terminal - well done,
>  but
>  I can't start program from Unity Launcher.
> 
>  I tried to change parameter Exec in
>  ~/.local/share/applications/app.desktop
>  Exec=app-name
>  Exec=snap-name.app-name
>  Exec=$SNAP/usr/bin/start-script.sh
>  Exec=$snap.$app (http://snapcraft.io/docs/snaps/structure)
> 
>  and studied case
> 
https://github.com/ubuntu/snappy-playpen/blob/master/vlc/setup/gui/vlc.desktop
> 
> 
> 
>  but it didn't help.
> 
> >>> suspect lines
> >>> Aug  6 10:20:35 vb gnome-session[2377]: (gnome-software:2582):
> >>> As-WARNING **: failed to rescan: Failed to parse
> >>>
/home/vasilisc/.local/share/applications/org-languagetool-gui-main.desktop
> >>>
> >>> file: cannot process file of type application/x-desktop
> >>>
> >>>
> >> Hey Vasilisc,
> >>
> >> You didn't provide your .desktop file in setup/gui/ directory. Do you
> >> mind doing this?
> >> I suspect your type is different from "Type=Application", which it
> >> should be.
> >> Didier
> >
> > I found a problem. My script-wrapper (usr/bin/run.sh) run java app
> > #!/bin/bash
> >  bla-bla-bla 
> > java -jar -Duser.home=$SNAP_USER_DATA $SNAP/usr/bin/languagetool.jar
> >
> > in snapcraft.yaml
> > apps:
> >   languagetool:
> > command: usr/bin/run.sh
> > plugs: [network, network-bind, x11, home, unity7]
> >
> >
> > If to attach the java-app to a panel Unity Launcher, then the file
> > (~/.local/shape/applications/org-languagetool-gui-main.desktop ) will
> > contain.
> >
> > [Desktop Entry]
> > Encoding=UTF-8
> > Version=1.0
> > Type=Application
> > Name=LanguageTool 3.4-SNAPSHOT
> > Icon=org-languagetool-gui-main
> > Exec=java -jar -Duser.home=/home/vasilisc/snap/languagetool/x1
> > /snap/languagetool/x1/usr/bin/languagetool.jar
> >
> > In a host-system can't execute a command (it's impossible)
> > java -jar -Duser.home=/home/vasilisc/snap/languagetool/x1
> > /snap/languagetool/x1/usr/bin/languagetool.jar
> >
> > I don't know what to do.
>
> You need to ship yourself your .desktop file, as you pointed via the vlc
> desktop file inside the snapcraft source.
>
> This one will have the correct Exec= after building it with snapcraft
> rather then one generated from unity.
>
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io 
> Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/snapcraft
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft