I have found a workaround that still allows you to start kate as root.
First, copy the original kate desktop file to your user's local location:
cp /usr/share/applications/org.kde.kate.desktop ~/.local/share/applications/org.kde.kate_as_root.desktop
Then replace Exec=kate -b %U
with the following:
Exec=if [ "$XDG_SESSION_TYPE" = "wayland" ]; then xhost +si:localuser:root && pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dbus-launch kate -b %U && xhost -si:localuser:root ; else pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true kate -b %U; fi;
And set the Name to "Kate as root" for your convenience.
Also, change InitialPreference
from 9 to lower value (in my case 8), so that open as root variant become less priority than opening as normal action, so when you left click on a file, it opens as normal.
My content of the ~/.local/share/applications/org.kde.kate_as_root.desktop
file is (excluding translations):
[Desktop Entry]
GenericName=Advanced Text Editor
Name=Kate as root
Comment=KDE Advanced Text Editor
MimeType=text/plain;
Exec=if [ "$XDG_SESSION_TYPE" = "wayland" ]; then xhost +si:localuser:root && pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dbus-launch kate -b %U && xhost -si:localuser:root ; else pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true kate -b %U; fi;
StartupNotify=true
X-KDE-HasTempFileOption=true
Icon=kate
X-DocPath=kate/index.html
Type=Application
Terminal=false
InitialPreference=8
X-DBUS-StartupType=Multi
X-DBUS-ServiceName=org.kde.kate
Categories=Qt;KDE;Utility;TextEditor;
StartupWMClass=kate
Now in kate when you are at situation of editing file without permissions, you can go to File -> Open in -> "Kate as root".
In the dialog you enter password, and you get the new kate window in which you do not need to enter password anymore.
Additionally, you can right click on a file in dolphin and choose Open with -> Kate as root.