Bug 394938 - Can't run .desktop files
Summary: Can't run .desktop files
Status: RESOLVED FIXED
Alias: None
Product: krusader
Classification: Applications
Component: general (show other bugs)
Version: 2.7.0
Platform: Kubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: Davide Gianforte
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-02 08:48 UTC by milkaca
Modified: 2020-05-24 07:34 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description milkaca 2018-06-02 08:48:55 UTC
By running .desktop file in normal mode, Kate will open the file.

If I run Krusader privileged mode (root) even Kate will not be opened.

Please fix this, .desktop files should be always executed, in "normal" and privileged mode (root).

This is my simple .desktop file for testing:

[Desktop Entry]  
Version=1.0  
Exec=sudo /usr/local/bin/test.sh
Name=Test
GenericName=Test
Comment=Execute test
Encoding=UTF-8  
Terminal=true
Type=Application
Categories=Application;Development;
MimeType=application/x-sharedlib;


Of course I tried various options like Terminal=false also playing with MimeType.
Comment 1 milkaca 2018-06-10 14:32:19 UTC
Can someone confirm this issue?
Comment 2 Theo 2018-06-11 00:00:39 UTC
Can confirm that Krusader in normal mode opens with associated application, even when I select "Run" in drop down menu. I'm not sure if I like what Dolphin is doing to the .desktop file: when I choose "Execute", Dolphin changes the content of the file by prepending "#!/usr/bin/env xdg-open" and modifies permissions without asking.
Comment 3 milkaca 2018-06-11 06:08:49 UTC
I think that at least behaviour should be the same in both modes (normal, root). Double commander is also executing files, do not see any problem there.
Comment 4 Nikita Melnichenko 2018-06-13 07:39:20 UTC
> Dolphin is doing to the .desktop file: when I choose "Execute", Dolphin changes the content of the file by prepending "#!/usr/bin/env xdg-open" and modifies permissions without asking

OMG, I confirm it's doing this. Not nice, IMO.

I think this type of functionality has never been implemented in Krusader before, so I move it to wish list.
Comment 5 milkaca 2018-06-13 07:54:25 UTC
Double commander is also executing file. Why do we have .desktop files, they should be shortcuts to execute something right? What is the use case to open .desktop file in some default text editor like Kate. Who needs that. :)

If you have "Exec" in desktop file then it should be executed or should I open it in Kate and copy/paste command in Terminal. :)
Comment 6 Nikita Melnichenko 2018-06-14 05:14:59 UTC
(In reply to amilino from comment #5)
> Why do we have .desktop files, they
> should be shortcuts to execute something right?

They are shortcuts for a menu or a desktop [1]:

 In GNOME and other freedesktop.org-compliant desktops, an application gets registered into the desktop's menus through a desktop entry, which is a text file with .desktop extension. This desktop file contains a listing of the configurations for your application. The desktop takes the information in this file and uses it to:

    put the application in the Main Menu. To find a list of valid categories, take a look into FreeDesktop.org's Desktop Menu Specification.
    list the application in the Run Application... dialog
    create appropriate launchers in the menu or on the desktop.
    associate the name and description of the application.
    use the appropriate icon.
    recognize the MIME types it supports for opening files.


> What is the use case to open
> .desktop file in some default text editor like Kate. Who needs that. :)
We do this for any text file. Consistency. You can modify association with this mime type and associate a program to run a desktop file. Don't ask me, I don't know such an app. :)

> If you have "Exec" in desktop file then it should be executed or should I
> open it in Kate and copy/paste command in Terminal. :)
Simply use a one-line shell script instead of a desktop file.


Since it is implemented in Dolphin, then someone else has cared about at some point in time and it becomes a signal that Krusader may need this as well. However, the current way Dolphin does it (by modifying contents and permissions) is a really bad practice. If you suggest to implement it differently, then we'll consider, but I think it should be governed by an external app and you simply set an appropriate association.


[1] https://developer.gnome.org/integration-guide/stable/desktop-files.html.en
Comment 7 milkaca 2018-06-14 16:42:08 UTC
I switched to shell files, I like Krusader too much to leave it because of this minor issue. However, I think you shoud keep up with all other file managers.

Can you at least make it work in root mode same as it works in normal mode? Currently if I run Krusader in root mode, file is not opened in text editor app.
Comment 8 Toni Asensi Esteve 2018-06-14 21:49:13 UTC
> If I run Krusader privileged mode (root) even Kate will not be opened.

> [...]

> Can you at least make it work in root mode same as it works in normal mode?
> Currently if I run Krusader in root mode, file is not opened in text editor app.

By default: if you press F4 on a file and you can edit it, then you are using Krusader's internal editor; and if you press Return on a file then... you launch Kate. Maybe your problem is not related to Krusader, maybe your problem is that your version of Kate doesn't work with root privileges (that happens under a lot of distributions - operating systems).

For example, in my Kubuntu 18.04 command line this is what happened:
    # kate
    Executing Kate as root is not possible. To edit files as root use:
    SUDO_EDITOR=kate sudoedit <file>

When running Krusader in root mode (because you need to copy/move/synchronize a lot of files in /usr/local/bin, etc.) you can use the internal editor of Krusader to edit files. If there is really no other way, you can free Kate (https://forum.kde.org/viewtopic.php?f=66&t=86637#p381463).
That reading is very, very instructing (and also thought-provoking, "am I cracking Linux?")
Comment 9 milkaca 2018-06-15 06:25:27 UTC
OMG! I will not do that. :) I am using F4 to edit files and it is working fine. All best.
Comment 10 Toni Asensi Esteve 2018-06-19 18:18:20 UTC
(In reply to amilino from comment #9)
> OMG! I will not do that. :) I am using F4 to edit files and it is working
> fine. All best.
Fortunately, KDE later saw some use cases where using a graphical program (like Kate) as the root user... was needed:
    - [Kate](https://bugs.kde.org/show_bug.cgi?id=387973) can once again be launched when logged in as the root user.
    - [allow Kate and Dolphin to be run with the root user account again](https://pointieststick.wordpress.com/2018/06/02/this-week-in-usability-productivity-part-21/).
Comment 11 milkaca 2018-06-19 19:46:32 UTC
Do you know ppa for new version of Kate?
Comment 12 Toni Asensi Esteve 2018-06-27 18:04:05 UTC
> Do you know ppa for new version of Kate?
No, if you find any, you can write its address here :-)