Proper way to inform user about permissions

What is the proper way to inform and instruct the user of a probably needed permission?

In my case it’s mostly about removable-media.
Should I put the following in the description
sudo snap connect mapton:removable-media :removable-media
together with some information or add a link to somewhere?


Seems a bit verbose though.

Is it possible from within my (java) snap check if and interface is connected or not?

you can use a command-chain script and snapctl to check if an interface is connected, see:

1 Like

Thank you @ogra, and the best way to check if the app is inside a snap?

pick an environment variable to your liking :wink:

$ snap run --shell <yoursnap>
...
$ env | grep SNAP
...
$ exit
$

Thanks, I will do that!

Here’s the result in java for anyone who’s interested.

public static boolean isConnected(String plugOrSlot) throws IOException, InterruptedException {
    var processBuilder = new ProcessBuilder(StringUtils.split(String.format("snapctl is-connected %s", plugOrSlot)));
    var process = processBuilder.start();

    return 0 == process.waitFor();
}

public static boolean isSnap() {
    var env = System.getenv();

    return env.containsKey("SNAP_ARCH") && env.containsKey("SNAP_INSTANCE_NAME");
}

Are there plans to include permission prompt dialogs in the Ubuntu desktop at any point in the future? Just like Android asks for permission to use the camera on behalf of an app for example.

2 Likes

This is what I ended up with, but I really do prefer the way @ppd is talking about.
Screenshot_20210305_152726

2 Likes

This is known on our roadmap as “prompting” and it is something we really want to do, but it will take a while before it is ready since it requires significant kernel/apparmor work before we can make use of it. When we have something closer to working we will share more info on the forum about it.

5 Likes