[Gambas-user] Gambas app run as root

Jose J. Rodriguez joe1962 at ...626...
Tue Oct 5 23:08:37 CEST 2010


On 10/1/10, IMP Technologies - Tajinder Singh <imp.tsingh at ...626...> wrote:
>
>  I have created a small basic interface for Fedora to change Plymouth theme.
>  But as changing theme requires to run some commands as root, I would like to
>  ask for root password before starting the application.
>  Similarly whenever we run 'system-config-boot' or other software that
>  requires root privileges.
>

Here's how I did it in the Main class of a system utility that manages
the kernel cpufreq settings:

<CODE>
' Gambas module file

PUBLIC SUB Main()
DIM Ret AS String

IF System.User.Id <> 0 THEN
   EXEC ["which", "gksu"] TO Ret
   IF InStr(Ret, "gksu") THEN
      EXEC ["gksu", Application.Path &/ "vcpufreq.gambas"]
   ELSE
      EXEC ["which", "kdesu"] TO Ret
      IF InStr(Ret, "kdesu") THEN
         EXEC ["kdesu", Application.Path &/ "vcpufreq.gambas"]
      ELSE
         PRINT "No gksu or kdesu available (try vcpufreq in a root terminal)..."
      ENDIF
   ENDIF
   QUIT
ELSE
   Global.root = TRUE
ENDIF

FMain.Show	' Show main form...

END
</CODE>


Regards,
Joe1962




More information about the User mailing list