Desktop.RunAsRoot, Desktop.RunAs

Ask about the individual Gambas components here.
Post Reply
User avatar
Posts: 1052
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight

Desktop.RunAsRoot, Desktop.RunAs

Post by BruceSteers »

For anyone's information an update to Desktop.RunAsRoot() has been made thanks to yours truly.

Desktop.RunAsRoot() now uses 'pkexec' by default as its sudoer. Desktop.RunAs() is a new method that allows to specify the username used for running a program.
Benoit wrote: [GB.DESKTOP]
* NEW: Desktop.RunAsRoot() now takes an optional argument to wait for the program ends, and now uses 'pkexec' by default.
* NEW: Desktop.RunAs() is a method similar as RunAsRoot() that takes the username used for running the program.
I added an option to set UserName and a Wait option.

Ben wasn't too keen on adding a UserName option to a "RunAsRoot" command as he said it "should" be root. kinda makes sense.

So he added my changes as a Desktop.RunAs() command that takes a UserName parameter (root by default)
then he modified the Desktop.RunAsRoot to run the new command without a username so it only runs as root but still now looks for pkexec first

So now with the gambas development branch if you wanted to simply create your own version of a GKSU command you could write the following gbs gambas script file.

#!/usr/bin/env gbs3
Use "gb.desktop"

That's it, If you saved that as /usr/bin/GSU and set the executable flag then you could type the following (or set a menu launcher command)
GSU pluma

GSU gambas3

etc, etc
of course that's as basic as it gets, you might want to handle the args a bit better but that the essential code :)

Shimples :)
If at first you don't succeed , try something different.
Post Reply