Bug 358368 - When associating an app with a new minetype, copy its existing desktop file rather than creating a new one from scratch
Summary: When associating an app with a new minetype, copy its existing desktop file r...
Status: CONFIRMED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-22 11:14 UTC by H.H.
Modified: 2018-09-01 02:47 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Showing my *.old file configuration (50.23 KB, image/png)
2016-01-22 11:15 UTC, H.H.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.H. 2016-01-22 11:14:47 UTC
For example:

I have my own definition (see screenshot) of file type "*.old" for kwrite with command "kwrite %u".

The files on "sftp://.../x.old" are opened from a local directory "~/.cache/kioexec/.." (and are not stored remotely on ctrl-s!!!).

If I use the right-click option "open with" and type "kwrite %u" it works like expected.


Reproducible: Always
Comment 1 H.H. 2016-01-22 11:15:33 UTC
Created attachment 96784 [details]
Showing my *.old file configuration
Comment 2 Frank Reininghaus 2016-01-24 10:35:29 UTC
Thanks for the bug report. Dolphin uses KRun from KIO to open files (Dolphin itself is entirely unaware of what application and what command line arguments are used when you open a file), so I'll reassign.
Comment 3 Nate Graham 2018-08-22 20:00:53 UTC
Is this still an issue with KDE Frameworks 5.49? How are you opening the files in the first place? Are you opening them from the "sftp://.." path with Dolphin or the file dialog, or directly from "~/.cache/kioexec/.."?
Comment 4 H.H. 2018-08-23 07:14:02 UTC
This is still an issue. With some file-extensions it works like expected, but with others like ".old" or ".jsp" it does not work.

I open them from dolphin (dolphin shows the sftp://user@domain/... path). When I open a file in kwrite, kwrite should show (you can make kwrite show the complete path in the title-bar) "sftp://..." and not "~/.cache/..". Also saving does not work in the last case.
Comment 5 H.H. 2018-08-23 07:15:24 UTC
When I manually open the right-click-submenu "open-with.." and type there "kwrite %u" it always works like expected, but this is too complicated, and often forgotten.
Comment 6 David Faure 2018-08-23 09:04:43 UTC
KRun ends up in KToolInvocation::startServiceByDesktopPath("/home/dfaure/.local/share/applications/kwrite-2.desktop"), so the problem is in klauncher (KLauncher::createArgs).

Ah, I found it.
KIO::DesktopExecParser::resultingArguments looks at which protocols the application supports. Since there's no X-KDE-Protocols entry in that desktop file (and no Categories=KDE either), we have to assume that sftp isn't supported (as we do with, say, LibreOffice or Firefox or whatever).

The never-ending problems of locally-created .desktop files....

I think that when associating an existing app with a new mimetype, we need to copy over the existing desktop file, not just create one from scratch.

Alternatively, or in addition, we could have a GUI for setting the supported protocols thing, but that's a bit too manual I guess.

Short-term workaround: add X-KDE-Protocols=KIO to your local .desktop file for kwrite.
Comment 7 H.H. 2018-08-23 18:47:23 UTC
Thanks, I'll try that, and I'm glad to have a workaround for now.
Comment 8 Nate Graham 2018-09-01 02:47:17 UTC
> (and are not stored remotely on ctrl-s!!!)
If KWrite performs atomic saves, this is Bug 397742, which should be fixed with https://phabricator.kde.org/D15180


> I think that when associating an existing app with a new mimetype,
> we need to copy over the existing desktop file, not just create one
> from scratch.
That sounds like a sensible solution to me. Let's keep thie bug report open to track that.