Seems to be working, though. I made a small script checking if my server is there and then confirming it in a kdialog. (Took it from my startup sync script.) For a change I added “[FONT=courier new]cp /root/a/t /root/b/t” [/FONT]where t is a simple text file only accessible by root. Adding the X-KDE-Username=root apparently does the cp command in the restricted root folder. The permissions seem to be there. However I added kdialog --msgbox “I am user $USER” which doesn’t show “root” but “kasi”. You have to enter the root password, BTW.
As suggested in your other thread it really is advisable to put your code into the script. If find it easier than the “one-liner”. As far as I can see you want to check if your router is there? This is what I did:
# this used to be my sync script
# kdialog --msgbox "hallo $USER"
# Send a ping to the server. Return 0 means it's there.
ping 192.168.130.239 -c 1
# assign it to variable servercheck
# Do the check:
if $servercheck -eq 0 ] ; then
# confirm it's there:
kdialog --msgbox "The server is there."
** # who is running this?
kdialog --msgbox "I am user $USER"
# Can I write in root's folder?
cp /root/a/t /root/b/t**
# Exit: Better start the server
kdialog --msgbox "Have a look. Are you at home at all? The server is gone with return: $servercheck"
(The comments were there for my own memory, not for lecturing. Who am I? Just translated them rather than deleting.)
The bold lines just helped me to understand. I simply checked in dolphin if “t” is copied. (Will have to clean up root’s folder, now.)
It’s very generic, created it by right-click on the desktop and select “create link to program” (if translation is correct). Interesting: “terminal=true” will give you more verbosity. I’d say this is the reason for not showing the user “root” but “kasi”:
QStandardPaths: runtime directory '/run/user/1000' is not owned by UID 0, but a directory permissions 0700 owned by UID 1000 GID 42
Yep, I got that. It’s just that your goal seems to be hard (possible at all?) to achieve. I know it’s tedious to ask “why” you want to do it. You might still share what you want to achieve by using a “one-liner” (as Henk said, it’s hardly a “command”) rather than starting a script. I can’t help there but maybe others can if they know what you are up to…
To run a script you must know where is it.
How do you know if the script running on the usb key is on /media/some/path/to/the/script, or /run/media/$USER/some/path/to/the/script, or if the usb disk in not mounted.
You got a point there. But I think one should be able to overcome that. Why not put the script itself on the desktop? Or, if that script needs to be “portable”, you can put another script on the desktop. That script can invoke the “mount” command:
**~ #** mount
/dev/sdc1 on /run/media/kasi/**BIOS-FLASH** type vfat (...)
You can search for the label of your USB drive (in my case “BIOS-FLASH” I just got at hand) and there’s the path to your “real” script. That seems to be more practicable than the one liner in a “.desktop file”.