I have a .desktop file whose Exec= line I want to be run as another user. In a systemd service file, I can achieve this with a User= and Group= option. How to do the same in a .desktop file?

  • systemd services are run as root, and so can switch user. Desktop files are run as the calling user, and so can't switch user. You may want to describe the bigger problem you're trying to solve; that should give you some useful guidance. – Stephen Harris Dec 28 '18 at 2:06
  • @StephenHarris Yes, I figured out that maybe it was possible to make the desktop file to prompt for superuser password in the GUI to effect the change. Something like gksudo does. – ARX Dec 28 '18 at 2:36
  • 1
    Is there a reason you can't just gksudo within the exec line? – Fox Dec 28 '18 at 5:51
  • 1
    @Fox None. Apparently, I just needed somebody with better judgement like you to tell me to just try it (doh!). Exec=gksudo -u wantedUser /path/to/cmd is all I needed. Thank you for the nudge. – ARX Dec 28 '18 at 23:56

Your Answer

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

Browse other questions tagged or ask your own question.