Detect UID of window

I’m trying to be clever and put in an extra visual warning when running programs as sudo/root (dolphin f ex).

I have created a color scheme with bright red color on the menu bar.

I tried looking for an attribute in “special application/window settings” but I can’t find any setting to see user.
Is it even possible to detect user of the window in kde?

Now that I’m here I might as well ask. I struggle to see the difference between special window and application settings menu, what IS the difference and when should I use them?

You should not be running GUI programs as root, that’s in general a very bad idea. Bright red colour will not make this practice any more safe or less prone to permission issues (including broken config files in your home directory) and weird bugs that nobody has predicted or tested for.


I was under the impression/people told me that the KDE community was nice and not full of elitists rather giving opinions than answering questions when you ask for help.

I appreciate you probably THINK you help, but in fact, you do the complete opposite.
I have seen responses like this on “elitist” forums since the dawn of time and all it does, is KILL any possible future response that ACTUALLY would answer MY QUESTION!
If you answered the question and THEN give extra advice I would applaud you, but this, NO, STOP!

I’m not really interested in your opinion on whether I should run “sudo su” before running every single line in cli, oh wait, I wanted to do THE EXACT SAME THING IN DOLPHIN!

So, I ask again, is there any way to detect UID on started windows in kde/plasma so I can use that in window/application settings (that I also asked what the difference is if anybody knows)?

Please calm down, the response they gave was not at all elitist :slightly_frowning_face: Their reply is not scaring future responses, but yours might.

No and there probably won’t be, it might have been possible in X11 but in Wayland I don’t think you can run windows as a separate user anymore for security reasons. I doubt that we would add a X11-specific rule when support is going to drop in the next few years. However, I did look around the kwin bugtracker and didn’t find an existing wishlist item so it might be worth asking there.

I believe the only difference between those two options is what fields are filled in, although there doesn’t seem to be a perceptible difference on my end, at least on Wayland.


Just a thought, maybe as an alternative. It is possible to quickly change the user account. Of course you have to enable the root access to Xorg first. If you need this often it can be worthwhile. GG, the former developer of Cinelerra-GG was exclusively root. And for the fearful, you can also paint the access with a bright red theme.

It’s not an opinion. Just pointing out the fact that what you’re trying to do is not advised and will have potentially unforeseen side-effects. I’m not pointing this out only for your benefit, but also for everyone else reading this and potentially getting a bad idea.

You’re, of course, free to do what you want, it’s your system, if you break it, you’ll fix it. But I’m not going to be part of it, lest I be blamed for any damage this causes to anyone else.

Sure, you can call me an elitist as much as you want, I don’t care. I don’t think that’s elitist, it’s common sense.



You clearly missed my whole point, but whatever.

Thanks! I’ll look into it!

I mean, I use Dolphin, I can always use the terminal inside dolphin to switch user and do whatever I want as root in cli so that’s not really the issue.

What makes me wonder is because if you actually use the included “open as root” available in right click menu, it clearly warns you that running as root is not advisable, so somehow the UID=0 is detected, I was just curious HOW that is made, and if I could use that to somehow change the color of the menu.
Edit. Never thought about it before, because sudo dolphin wont let me open it in terminal. But if I force open it (pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dbus-launch dolphin), the warning is no longer there, so it might be a dolphin thing passed with the “open as root”…

IMHO, visual warnings are never a bad thing, in bash I simply change the color of the text for the root user, I just wanted something similar in my gui if possible.
There have been multiple times in the past where I have been interrupted for one reason or another wile doing things that demanded root access, and when you come back, its VERY easy to forget/miss things and you start doing something else, and the text coloring have saved me from headaches more than once.

1 Like

In this Dolphin (Debian 4:22.12.3-1) there is nothing like that. But Kate and Co. allow editing of root files until it comes to saving, then you should know the root password. Emacs, on the other hand, opens these files read-only, so it goes the other way.

The topic overlaps with How to run GUI app as superuser?

Yeah, I’m curious now too, I can see there is a plugin/dependency available for Dolphin for this (System / KIO Admin Worker · GitLab), but I don’t have that installed, but still the “open as root” is there!! I do however have the kio extras installed, so it might be something included in that.
I have to dive a bit deeper into this.

I’m marking your response as a solution so ppl can transition into that if they find this post.

Ah, you have installed kdeadmin and / or kio-admin. Sure, it should also allow stunts like dolphin admin:///.

I even had it installed once, along with the other 149 packages needed for it. But it was unstable and because I am too sensitive when it comes to my data, I uninstalled it immediately.

Merge requests: Make “don’t run me with sudo/kdesu” message informative

No, I do NOT have those, can’t find anything related to kdeadmin, and kio-admin, as I stated above is NOT installed on my system.
But as you stated, it probably comes in some OTHER package, I’m ok with that although it would be nice to know exactly what package that opens up that possibility.
Could be knewstuff, or kio-extras maybe, I haven’t looked through what is included tbh.
If I just spend some time looking for it, I’ll probably find it, but I kinda WANT this functionality, so it’s all good. :smiley:

1 Like


I figured out how to do it. Simply change the theme or colors in the configuration files for kde in /root. I figured this out when I was forced to edit the files when the behavior of clicking in dolphin suddenly changed, changing it on my user did not change it for root and that gave me this idea.

I use now use a dark theme for my user and set root to lighter theme. If I “run as root” the window will then be in a completely different color and very hard to miss that I am using it as root. :smiley: