I just made this today.
It occurred to me that i could possibly get an app to launch as root by creating a hidden TerminalView object and running the application with sudo through it, using the TerminalView.Input() method to send the password.
Turns out it can
so this app is called groot. It's tiny, not much code.
It simply takes any provided arguments , puts 'sudo' in front of it and executes in the hidden terminaview.
Kinda works like that pkAppMan thing i made but without all the flaffing about with pkexec policies
Just run the install script to copy it to your /usr/bin folder then you can set menu items and desktop launchers and the like to sudo up your apps.
Has an option to just run as normal user too.
after installing it you could for example copy your pluma text editor menu launcher onto your desktop and change it's command from
'pluma %U' to
'groot pluma %U'
then either clicking the launcher or dragging files onto it will give you the option to run as root or not
Like i said not much code to it really..
' Gambas class file Public aArgs As String Public pTermProc As Process Public Sub Form_Open() mbxPass.Password = True ' makes the text in the MaskBox show as *** ' If no arguments have been passed then there's nothing to do. If Args.Count = 1 Then Message("No arguments passed, Exitting.") Stop Event Me.Close() Return Endif aArgs = Args.All.Copy() ' Copy the arguments passed aArgs.Delete(0) ' remove the 1st Argument as it's groot ' Set the label text file info lblInfo.Text = "Application: " & File.Name(aArgs) & "\nPath: " & File.Dir(aArgs) End Public Sub btnOK_Click() If mbxPass.Text = "" Then ' No password was entered so see if we want to continue or not If Message.Warning("No password entered.\nRun " & File.Name(Args) & " without superuser rights?", "Yes", "No") <> 1 Then Me.Close() Return Endif ' User did not cancel so run without root. RunCommand(False) Else ' Password has been entered so go for root... aArgs.Add("sudo", 0) ' insert 'sudo' as first argument RunCommand() Endif End Public Sub btnNoRoot_Click() ' Just run the command without sudo RunCommand(False) End Public Sub RunCommand(Optional AsRoot As Boolean = True) Me.Visible = False ' hide window ' if not running as root just Exec the command without teminalview and quit. If Not AsRoot Then Exec aArgs Me.Close Return Endif ' create a terminalview object to run sudo in Dim TermV As TerminalView TermV = New TerminalView(Me) ' Execute the command creating the Process. pTermProc = TermV.Exec(aArgs) ' give it a moment then send the root password Wait 0.8 TermV.Input(mbxPass.Text & gb.Lf) ' Wait for the process to finish before quiting so as not to invalidate the process stream. While pTermProc.State = Process.Running Wait 0.5 Wend ' Command has finished so we can clean up and exit. If pTermProc Then pTermProc.Kill() Me.Close() End Public Sub btnCancel_Click() Print "User cancelled superuser request." Me.Close End ' Show and hide again the password on holding the button down. Public Sub btnShow_MouseDown() mbxPass.Password = False End Public Sub btnShow_MouseUp() mbxPass.Password = True mbxPass.SetFocus End ' user pressed RETURN after password Public Sub mbxPass_Activate() btnOK_Click() End