Bug 504967

Summary: in root mode, editor specified in Konfigurator>Basic Operations>Viewer/Editor>Editor window is ignored
Product: [Applications] krusader Reporter: muh2lintech
Component: generalAssignee: Krusader Bugs Distribution List <krusader-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: krusader-bugs-null, toni.asensi
Priority: NOR    
Version First Reported In: 2.8.1   
Target Milestone: ---   
Platform: Mint (Ubuntu based)   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description muh2lintech 2025-05-29 15:51:53 UTC
SUMMARY
When running Krusader ver 2.8.1 in root-privileged mode, the editor I specified in Konfigurator>Basic Operations>Viewer/Editor>Editor field is ignored. It uses xed instead.
What I put in the window:
sudo -u user1 /usr/bin/kate

sudo is necessary because kate will refuse to run as root.

Even if I just use /usr/bin/kate by itself, Krusader ignores it.

Why is this? 

STEPS TO REPRODUCE
1. run Krusader in root mode
2. put sudo -u username-f16 /usr/bin/kate in Konfigurator>Basic Operations>Viewer/Editor>Editor field
3. exit Krusader
4. start Krusader in root mode
5. double-click on a text file


OBSERVED RESULT
 xed is used instead of kate


EXPECTED RESULT
kate would be used instead of xed or any other editor

SOFTWARE/OS VERSIONS
System:
  Kernel: 6.8.0-60-generic arch: x86_64 bits: 64 compiler: gcc v: 13.3.0 clocksource: tsc
  Desktop: Cinnamon v: 6.4.8 tk: GTK v: 3.24.41 wm: Muffin v: 6.4.1 vt: 7 dm: LightDM v: 1.30.0
    Distro: Linux Mint 22.1 Xia base: Ubuntu 24.04 noble
Comment 1 Toni Asensi Esteve 2025-06-08 21:34:25 UTC
Dear reporter, I could not reproduce your problem (using Kubuntu 25.04 and the git version of Krusader).
Can you:
- Execute `sudo -i krusader` (just in case, to try to avoid what is described in <https://askubuntu.com/questions/539494/how-to-force-krusader-to-use-ubuntus-file-associations/835963#835963>, as seen on <https://unix.stackexchange.com/questions/35338/su-vs-sudo-s-vs-sudo-i-vs-sudo-bash/35342#35342>).
- Write your `sudo -u username-f16 /usr/bin/kate` command in "Settings > Configure Krusader > General > Viewer/Editor > Editor field".
- Exit Krusader.
- Execute `sudo -i krusader`.
- Double-click on a text file.
?

If the problem persists, could you perform the same steps although writing `sudo -u username-f16 -H /usr/bin/kate` (instead of `sudo -u username-f16 /usr/bin/kate`) in "Settings > Configure Krusader > General > Viewer/Editor > Editor field"?
Comment 2 Toni Asensi Esteve 2025-06-09 19:11:32 UTC
If you use F4 to edit the text file (instead of double-clicking the file), do you find any problem?

If you execute
    sudo -i
    xdg-mime query default text/plain
what do you see?

If you press Alt+Return on a file, can you find an option to change the program that is used to open text files? 
To open text files, can you use a shell script that executes your `sudo -u username-f16 /usr/bin/kate` command?
Comment 3 Bug Janitor Service 2025-06-24 03:47:43 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 4 muh2lintech 2025-06-27 21:53:05 UTC
I need a little more time to get to this. I hope this comment keeps the bug alive.
Comment 5 muh2lintech 2025-06-28 18:15:48 UTC
Hi Toni, 

First, thank you for your informative responses.

I tried:
- Write your `sudo -u username-f16 /usr/bin/kate` command in "Settings > Configure Krusader > General > Viewer/Editor > Editor field".
- Exit Krusader.
- Execute `sudo -i krusader`.
- Double-click on a text file.

and it loaded Xed instead of Kate.

I then tried:
If the problem persists, could you perform the same steps although writing `sudo -u username-f16 -H /usr/bin/kate` (instead of `sudo -u username-f16 /usr/bin/kate`) in "Settings > Configure Krusader > General > Viewer/Editor > Editor field"?

and it loaded Xed instead of Kate.

But it worked when I:
If you use F4 to edit the text file (instead of double-clicking the file), do you find any problem?

So, hitting F4 loads Kate instead of Xed, but double-clicking on a file loads Xed.

I also tried:
root@framework-16:~# xdg-mime query default text/plain
org.x.editor.desktop
root@framework-16:~# 

I checked the file /usr/share/applications/org.x.editor.desktop.
At the bottom it says:

Exec=xed %U
Terminal=false
Type=Application
StartupNotify=true
MimeType=text/plain;application/x-zerosize;
Icon=accessories-text-editor
Categories=GTK;Utility;TextEditor;
Keywords=xed;text;editor;tabs;highlighting;code;multiple;files;pluggable;notepad;
X-MATE-DocPath=xed/xed.xml
Actions=new-window;

[Desktop Action new-window]
Name=New Window
Exec=xed --new-window %U

If I were to replace xed with kate, would that enable double-clicking on a file in Krusader to use kate all the time?
Comment 6 Toni Asensi Esteve 2025-06-29 21:18:49 UTC
I wrote "If you press Alt+Return on a file, can you find an option to change the program that is used to open text files?" to try to associate text files with Kate; in the end, the way depends on your system (you wrote "Desktop: Cinnamon v: 6.4.8 tk: GTK v: 3.24.41 wm: Muffin v: 6.4.1 vt: 7 dm: LightDM v: 1.30.0
Distro: Linux Mint 22.1 Xia base: Ubuntu 24.04 noble").
    
> If I were to replace xed with kate, would that enable double-clicking on a file in Krusader to use kate all the time?
Maybe that will work (it depends on your system).

> So, hitting F4 loads Kate instead of Xed, but double-clicking on a file loads Xed.
> [More information]
OK, it's not a Krusader bug. I will close this bug report.
Comment 7 muh2lintech 2025-07-08 16:54:32 UTC
It WORKED!! 
"If you press Alt+Return on a file, can you find an option to change the program that is used to open text files?" to try to associate text files with Kate;

After setting up the various options, eg. running kate as a user other than root, it worked.

Thank you Toni, you're a great help!