7

I'm using the Kate editor ver 16.04.2 on live knoppix 7.7.1 on a usb stick.

When I double-click on a normal text file in pcmanfm, Kate opens but it replaces the spaces in the filename with %20, and a message says "New", which I presume means "new file". The contents of the file I double-clicked on do not appear in Kate, but the text window is empty.

Say the true filename is my notes, then Kate changes it to my%20notes.

If I open Kate separately, then opening the file in the following ways DOES work:

  • Using File/Open from Kate's menu, and selecting the file from there.
  • Clicking and dragging the file from pcmanfm across to the Kate window.

On my main Debian system on the hard drive, Kate opens a double-clicked file fine. Why does the double-click opening method replace spaces with %20, and how do I fix it?


Edit:

I did the following tests (on the live knoppix 7.7.1 on usb stick). They may help in identifying what the remedy is for my problem.

Using pcmanfm

(This is the same scenario I've already described in my original question.)

Kate was already the default application that's launched when a text file is double-clicked. I double-clicked the file my notes in pcmanfm, but Kate opened a NEW file called my%20notes, with nothing in it.

While Kate was still open, I did the following to see what filename was passed to Kate:

$ ps ax | grep kate
4893 tty5     Sl     0:01 kate -b file:///home/knoppix/my%20notes

I changed the default launch application from Kate to KWrite. When I double-clicked my notes, KWrite opened a NEW file called my%20notes.

I changed the default launch application to Leafpad. When I double-clicked my notes, Leafpad CORRECTLY opened my notes.

Using nautilus file manager:

I set the default launch application to Kate. When I double-clicked my notes, Kate CORRECTLY opened my notes (ie no %20 used).

Conclusions

It seems to be ONLY pcmanfm (not other file managers, such as nautilus) that causes %20 to be used in Kate. Also it seems to be KDE launch applications (Kate and KWrite) in which the %20 problem occurs -- but only via pcmanfm. I don't think pcmanfm itself is a KDE application.

  • I don't know why it replaces it but hex20 is the ascii code for SPACE. – C.W. Jun 4 '18 at 20:26
  • 1
    hint: can you see the full command-line passed to kate, if you run the command ps -ax in a terminal while kate is still running? (Close any existing kate windows before double-clicking the file. The recently started processes will be at the end of the ps output). – sourcejedi Jun 4 '18 at 20:26
  • you could also check the .desktop file for kate or org.kde.kate, in /usr/share/applications, and compare the Exec= line with the "field codes" here: standards.freedesktop.org/desktop-entry-spec/latest/… – sourcejedi Jun 4 '18 at 20:30
  • Based on that ps output, pcmanfm is passing a URL to kate instead of a filename. %20 is a URL-encoded space, and the file protocol lets you access local files -- if you went to file:///home/knoppix/my%20notes in a browser it would work. Kate is a text editor and doesn't understand URLs. It's likely that pcmanfm is passing URLs regardless of application; it happens that Leafpad can handle them and open the file normally. You need to figure out why pcmanfm is using URLs. How are you setting the launch app? You might try a custom command-line and set it to /usr/bin/kate %f – Michael Mrozek Jun 6 '18 at 5:29
0

I've found the cure!

I'm using the LXDE desktop environment, and did the following to fix the problem.

Select the KMenu icon at the left end of the Desktop Panel at the bottom of the screen. Select Accessories/MainMenu. When the MainMenu application appears, click on Accessories in the left box, then click on Kate in the middle box, then click on Properties at the right.

In the "Command" box, replace "kate -b %U" with "kate -b".

When I now double-click a text file in pcmanfm, Kate correctly opens the file, ie spaces aren't replaced with %20.

I don't have much knowlegde of the percent parameters (like %U), but I've a feeling that %U might mean "Treat the argument supplied to Kate as a URL" (not as a normal file).

Thanks immensely sourcejedi and Michael Mrozek for putting me on the path to the solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.