slitaz-tools diff oldstuff/subox @ rev 585
Rename stuff to oldstuff and mv subox to it
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Apr 30 01:29:28 2011 +0200 (2011-04-30) |
parents | tinyutils/subox@9ccc4f26da15 |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/oldstuff/subox Sat Apr 30 01:29:28 2011 +0200 1.3 @@ -0,0 +1,114 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# Gtkdialog to execute program as root from a WM menu. 1.7 +# (c) SliTaz GNU/Linux 2008-2010 - GNU gpl. 1.8 +# 1.9 +VERSION=20100324 1.10 + 1.11 +# Usage. 1.12 +if [ -z "$1" ]; then 1.13 + echo "Slitaz subox version : $VERSION" 1.14 + echo -e "\nUsage : subox program\n" 1.15 + exit 0 1.16 +fi 1.17 + 1.18 +# Nothing to do if we are root 1.19 +test $(id -u) = 0 && exec $1 1.20 + 1.21 +# Include gettext helper script. 1.22 +. /usr/bin/gettext.sh 1.23 + 1.24 +# Export package name for gettext. 1.25 +TEXTDOMAIN='subox' 1.26 +export TEXTDOMAIN 1.27 + 1.28 +# Keep command in an exported variable to be used by SU_DIALOG. 1.29 +export SU_CMD=$1 1.30 + 1.31 +# Error window if the pwd is wrong. 1.32 +export ERROR_DIALOG=' 1.33 +<window title="Subox"> 1.34 + <vbox> 1.35 + 1.36 + <text use-markup="true"> 1.37 + <label>" 1.38 +<b>SliTaz - Subox</b>" 1.39 + </label> 1.40 + </text> 1.41 + <text wrap="true" width-chars="48"> 1.42 + <label>"'`gettext "Error: wrong password!"`'"</label> 1.43 + </text> 1.44 + 1.45 + <hbox> 1.46 + <button ok></button> 1.47 + </hbox> 1.48 +</vbox> 1.49 +</window> 1.50 +' 1.51 + 1.52 +# Main window and root password default entry set to 'root'. 1.53 +SU_DIALOG=' 1.54 +<window title="Subox" skip_taskbar_hint="true"> 1.55 +<vbox> 1.56 + 1.57 + <text use-markup="true"> 1.58 + <label>" 1.59 +<b>SliTaz - Subox</b>" 1.60 + </label> 1.61 + </text> 1.62 + <text wrap="true" width-chars="50"> 1.63 + <label>"'`gettext " 1.64 +Please enter root password (default root) to execute :"`' 1.65 +'$@' 1.66 +" 1.67 + </label> 1.68 + </text> 1.69 + 1.70 + <hbox> 1.71 + <text use-markup="true"> 1.72 + <label>"'`gettext "<b>Admin password :</b>"`'"</label> 1.73 + </text> 1.74 + <entry visibility="false">' 1.75 + 1.76 +# Check if we have a saved passwd. 1.77 +if [ -s $HOME/.config/slitaz/subox.conf ]; then 1.78 + PASSWD=`cat $HOME/.config/slitaz/subox.conf` 1.79 + [ -n "$PASSWD" ] && SU_DIALOG="$SU_DIALOG <default>$PASSWD</default>" && AUTO_SAVED_PASSWD=true 1.80 +else 1.81 +AUTO_SAVED_PASSWD=false 1.82 +fi 1.83 + 1.84 +export SU_DIALOG=''${SU_DIALOG}' 1.85 + <variable>PASSWD</variable> 1.86 + </entry> 1.87 + </hbox> 1.88 + 1.89 + <hbox> 1.90 + <checkbox> 1.91 + 1.92 + <label>"'`gettext "Autosave password"`'"</label> 1.93 + <variable>AUTOSAVE</variable>' 1.94 +if [ $AUTO_SAVED_PASSWD = "true" ] 1.95 + then SU_DIALOG="$SU_DIALOG <default>true</default>" 1.96 + else SU_DIALOG="$SU_DIALOG <default>false</default>" 1.97 +fi 1.98 + 1.99 +export SU_DIALOG=''${SU_DIALOG}' 1.100 + 1.101 + </checkbox> 1.102 + <button ok> 1.103 + <action> echo $PASSWD | su -c "$SU_CMD &" || gtkdialog --center --program=ERROR_DIALOG</action> 1.104 + <action>[ $AUTOSAVE == true ] && echo $PASSWD > '$HOME/.config/slitaz/subox.conf'</action> 1.105 + <action>[ $AUTOSAVE == true ] && chmod 0600 '$HOME/.config/slitaz/subox.conf'</action> 1.106 + <action>[ $AUTOSAVE == false ] && cat /dev/null > '$HOME/.config/slitaz/subox.conf'</action> 1.107 + <action type="closewindow">SU_DIALOG</action> 1.108 + </button> 1.109 + <button cancel></button> 1.110 + </hbox> 1.111 + 1.112 +</vbox> 1.113 +</window>' 1.114 + 1.115 +gtkdialog --center --program=SU_DIALOG > /dev/null 1.116 + 1.117 +exit 0