Giter Club home page Giter Club logo

Comments (8)

Tommimon avatar Tommimon commented on August 31, 2024 1

As you can see I changed the shortcut implementation, now I'm coping the original .desktop file.

No more pkexec and no more sudo prompt.

Feel free to download and test this new update, just clone master branch and use it as your extension folder. Now it is compatible with every gnome-shell after 3.28 afaik.

If this works without any problem we can close this issue because pkexec is gone, let me know.

from add-to-desktop.

Tommimon avatar Tommimon commented on August 31, 2024

I don't agree, root owns preinstalled application at /usr/share/applications and I believe you need sudo for those apps, tell me if I'm missing something.

If avoiding pkexec is so important I'm planning to add a new mode to use copy of the launcher files instead of using links, for copies chmod is not required.

I have some idea to solve the copy related problems pointed out in the README.md

For this to happen you need a bit of patience

from add-to-desktop.

kunver400 avatar kunver400 commented on August 31, 2024

Gio can wrtite permissions if extension is installed in /usr/share/gnome-shell/extensions/

i think copying .desktop file will also require changing permissions, this is what i am using currently, works just fine

_createLink() {
    let desktop = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
    let src = Gio.File.new_for_path(this._appPath);
    let dst = Gio.File.new_for_path(GLib.build_filenamev([desktop, src.get_basename()]));
    try {
        src.copy(dst, Gio.FileCopyFlags.OVERWRITE, null, null);
        this._markTrusted(dst);
    } catch (e) {
        log(`Failed to copy to desktop: ${e.message}`);
    }
}
async _markTrusted(file) {
    let modeAttr = Gio.FILE_ATTRIBUTE_UNIX_MODE;
    let trustedAttr = 'metadata::trusted';
    let queryFlags = Gio.FileQueryInfoFlags.NONE;
    let ioPriority = GLib.PRIORITY_DEFAULT;

    try {
        let info = await file.query_info_async(modeAttr, queryFlags, ioPriority, null);
        let mode = info.get_attribute_uint32(modeAttr) | 0o100;
        info.set_attribute_uint32(modeAttr, mode);
        info.set_attribute_string(trustedAttr, 'yes');
        await file.set_attributes_async(info, queryFlags, ioPriority, null);
    } catch (e) {
        log(`Failed to mark file as trusted: ${e.message}`);
    }
}

from add-to-desktop.

Tommimon avatar Tommimon commented on August 31, 2024

I will try this as soon as possible, thanks for spending your time on this project.

Just to be clear you say that automatic installed extensions can edit root owned files without asking for password? This seems very insecure to me.

from add-to-desktop.

Tommimon avatar Tommimon commented on August 31, 2024

What you are doing with this code is creating a copy of the original .desktop file stored at this._appPath, this method avoids pkexec.

That said this extension uses soft links instead and with your code you are not making any soft link, the reason to use links instead of copies is pointed out in README.md in section 'How does it work'.

I will add copies support but I have to automatically solve those problems.

from add-to-desktop.

kunver400 avatar kunver400 commented on August 31, 2024

I will try this as soon as possible, thanks for spending your time on this project.

Just to be clear you say that automatic installed extensions can edit root owned files without asking for password? This seems very insecure to me.

I think most users won't like a sudo prompt for adding desktop shortcuts, and that's how it works with most core gnome-shell-extensions @ https://github.com/GNOME/gnome-shell-extensions, you can add an option for installing as builtin

What you are doing with this code is creating a copy of the original .desktop file stored at this._appPath, this method avoids pkexec.

That said this extension uses soft links instead and with your code you are not making any soft link, the reason to use links instead of copies is pointed out in README.md in section 'How does it work'.

I will add copies support but I have to automatically solve those problems.

both soft links and desktop files should work, my example just happens to use desktop entries.

from add-to-desktop.

Tommimon avatar Tommimon commented on August 31, 2024

I think most users won't like a sudo prompt for adding desktop shortcuts

I think you are right, this layout isn't the best, we should find a better solution.

you can add an option for installing as builtin

Honestly If you explain it more I would appreciate it but I prefer if the extension works pretty much the same with any kind of installation. In fact you can always copy the original desktop file to the Desktop folder with no sudo, no matter how you installed the extension.

I will work on that in the next days (starting today), tell me if you have something more to say about it

from add-to-desktop.

kunver400 avatar kunver400 commented on August 31, 2024

@Tommimon Sounds great.
I am using a modified version currently, will try out the new one once i get a chance.

from add-to-desktop.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.