slitaz-tools view oldstuff/subox @ rev 625

Gettextize setmixer and make pot
author Christophe Lincoln <pankso@slitaz.org>
date Tue Jun 14 22:47:24 2011 +0200 (2011-06-14)
parents 9ccc4f26da15
children
line source
1 #!/bin/sh
2 #
3 # Gtkdialog to execute program as root from a WM menu.
4 # (c) SliTaz GNU/Linux 2008-2010 - GNU gpl.
5 #
6 VERSION=20100324
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 # Include gettext helper script.
19 . /usr/bin/gettext.sh
21 # Export package name for gettext.
22 TEXTDOMAIN='subox'
23 export TEXTDOMAIN
25 # Keep command in an exported variable to be used by SU_DIALOG.
26 export SU_CMD=$1
28 # Error window if the pwd is wrong.
29 export ERROR_DIALOG='
30 <window title="Subox">
31 <vbox>
33 <text use-markup="true">
34 <label>"
35 <b>SliTaz - Subox</b>"
36 </label>
37 </text>
38 <text wrap="true" width-chars="48">
39 <label>"'`gettext "Error: wrong password!"`'"</label>
40 </text>
42 <hbox>
43 <button ok></button>
44 </hbox>
45 </vbox>
46 </window>
47 '
49 # Main window and root password default entry set to 'root'.
50 SU_DIALOG='
51 <window title="Subox" skip_taskbar_hint="true">
52 <vbox>
54 <text use-markup="true">
55 <label>"
56 <b>SliTaz - Subox</b>"
57 </label>
58 </text>
59 <text wrap="true" width-chars="50">
60 <label>"'`gettext "
61 Please enter root password (default root) to execute :"`'
62 '$@'
63 "
64 </label>
65 </text>
67 <hbox>
68 <text use-markup="true">
69 <label>"'`gettext "<b>Admin password :</b>"`'"</label>
70 </text>
71 <entry visibility="false">'
73 # Check if we have a saved passwd.
74 if [ -s $HOME/.config/slitaz/subox.conf ]; then
75 PASSWD=`cat $HOME/.config/slitaz/subox.conf`
76 [ -n "$PASSWD" ] && SU_DIALOG="$SU_DIALOG <default>$PASSWD</default>" && AUTO_SAVED_PASSWD=true
77 else
78 AUTO_SAVED_PASSWD=false
79 fi
81 export SU_DIALOG=''${SU_DIALOG}'
82 <variable>PASSWD</variable>
83 </entry>
84 </hbox>
86 <hbox>
87 <checkbox>
89 <label>"'`gettext "Autosave password"`'"</label>
90 <variable>AUTOSAVE</variable>'
91 if [ $AUTO_SAVED_PASSWD = "true" ]
92 then SU_DIALOG="$SU_DIALOG <default>true</default>"
93 else SU_DIALOG="$SU_DIALOG <default>false</default>"
94 fi
96 export SU_DIALOG=''${SU_DIALOG}'
98 </checkbox>
99 <button ok>
100 <action> echo $PASSWD | su -c "$SU_CMD &" || gtkdialog --center --program=ERROR_DIALOG</action>
101 <action>[ $AUTOSAVE == true ] && echo $PASSWD > '$HOME/.config/slitaz/subox.conf'</action>
102 <action>[ $AUTOSAVE == true ] && chmod 0600 '$HOME/.config/slitaz/subox.conf'</action>
103 <action>[ $AUTOSAVE == false ] && cat /dev/null > '$HOME/.config/slitaz/subox.conf'</action>
104 <action type="closewindow">SU_DIALOG</action>
105 </button>
106 <button cancel></button>
107 </hbox>
109 </vbox>
110 </window>'
112 gtkdialog --center --program=SU_DIALOG > /dev/null
114 exit 0