slitaz-tools view tinyutils/subox @ rev 340
tazx: Moved doc to Handbook
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon May 04 23:12:18 2009 +0200 (2009-05-04) |
parents | db0e82bebc70 |
children | 8ec105954ae9 |
line source
1 #! /bin/sh
2 #
3 # Gtkdialog to execute program as root from a WM menu.
4 # - SliTaz GNU/Linux 2008.
5 #
6 VERSION=20080113
8 # Usage.
9 if [ -z "$1" ]; then
10 echo "Slitaz subox version : $VERSION"
11 echo -e "\nUsage : subox program\n"
12 exit 0
13 fi
15 # Nothing to do if we are root
16 test $(id -u) = 0 && exec $1
18 # Keep binary name in a tmp file to be used by SU_DIALOG.
19 echo "$1" > /tmp/subox-exec
21 # Main window and root password default entry set to 'root'.
22 export SU_DIALOG='
23 <window title="Subox">
24 <vbox>
26 <text use-markup="true">
27 <label>
28 "
29 <b>SliTaz - Subox</b>"
30 </label>
31 </text>
32 <text wrap="true" width-chars="46">
33 <label>
34 "
35 Please enter root password to execute :"
36 </label>
37 </text>
38 <text>
39 <input file>/tmp/subox-exec</input>
40 </text>
42 <hbox>
43 <text use-markup="true">
44 <label>"<b>Root password :</b>"</label>
45 </text>
46 <entry visibility="false">
47 <default>root</default>
48 <variable>PASSWD</variable>
49 </entry>
50 </hbox>
52 <hbox>
53 <button ok>
54 <action>echo $PASSWD | su -c "`cat /tmp/subox-exec`" &</action>
55 <action type="closewindow">SU_DIALOG</action>
56 </button>
57 <button cancel></button>
58 </hbox>
60 </vbox>
61 </window>
62 '
64 gtkdialog --center --program=SU_DIALOG
66 # Let other user lauch subox.
67 rm /tmp/subox-exec