slitaz-tools rev 275

Add SliTaz Control Box (gui, icon and desktop file)
author Christophe Lincoln <pankso@slitaz.org>
date Mon Nov 24 21:37:09 2008 +0100 (2008-11-24)
parents 682760cabf36
children 271fa5c34473
files rootfs/usr/share/applications/tazctrlbox.desktop rootfs/usr/share/pixmaps/tazctrlbox.png tinyutils/tazctrlbox
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rootfs/usr/share/applications/tazctrlbox.desktop	Mon Nov 24 21:37:09 2008 +0100
     1.3 @@ -0,0 +1,9 @@
     1.4 +[Desktop Entry]
     1.5 +Encoding=UTF-8
     1.6 +Name=Control Box
     1.7 +Name[fr]=Boîte de contrôle
     1.8 +Comment=Manage your SliTaz system
     1.9 +Exec=subox tazctrlbox
    1.10 +Icon=tazctrlbox.png
    1.11 +Type=Application
    1.12 +Categories=System;Application;
     2.1 Binary file rootfs/usr/share/pixmaps/tazctrlbox.png has changed
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tinyutils/tazctrlbox	Mon Nov 24 21:37:09 2008 +0100
     3.3 @@ -0,0 +1,452 @@
     3.4 +#!/bin/sh
     3.5 +#
     3.6 +# SliTaz Control Box is a tool to configure and manage a SliTaz system.
     3.7 +# The script use GTKdialog for the UI interface, some shell functions
     3.8 +# are called by argument. Individual window dialog are put into 
     3.9 +# functions.
    3.10 +#
    3.11 +# (C) GNU gpl v3 - SliTaz GNU/Linux 2008.
    3.12 +# Author: Christophe Lincoln <pankso@slitaz.org>
    3.13 +#
    3.14 +VERSION=1.0
    3.15 +
    3.16 +# Get init configuration.
    3.17 +. /etc/rcS.conf
    3.18 +
    3.19 +# Tazctrlbox is only for root.
    3.20 +if test $(id -u) != 0 ; then
    3.21 +	exec subox $0
    3.22 +	exit 0
    3.23 +fi
    3.24 +
    3.25 +# Change Grub menu.lst timeout.
    3.26 +sed_grub_timeout()
    3.27 +{
    3.28 +	CURRENT=`cat /boot/grub/menu.lst | grep ^timeout | cut -d " " -f2`
    3.29 +	sed -i s/"timeout $CURRENT"/"timeout $GRUB_TIMEOUT"/ /boot/grub/menu.lst
    3.30 +}
    3.31 +
    3.32 +# Change Grub menu.lst timeout.
    3.33 +sed_grub_color()
    3.34 +{
    3.35 +	CURRENT=`cat /boot/grub/menu.lst | grep ^color | cut -d " " -f2-3`
    3.36 +	sed -i s#"color $CURRENT"#"color $GRUB_COLOR"# /boot/grub/menu.lst
    3.37 +}
    3.38 +
    3.39 +# Set checked fs on boot.
    3.40 +sed_check_fs()
    3.41 +{
    3.42 +	sed -i s#"CHECK_FS=\"$CHECK_FS\""#"CHECK_FS=\"$NEW_CHECK_FS\""# \
    3.43 +		/etc/rcS.conf
    3.44 +}
    3.45 +
    3.46 +# Set loaded modules on boot.
    3.47 +sed_load_modules()
    3.48 +{
    3.49 +	sed -i s/"LOAD_MODULES=\"$LOAD_MODULES\""/"LOAD_MODULES=\"$NEW_MODULES\""/ \
    3.50 +		/etc/rcS.conf
    3.51 +}
    3.52 +
    3.53 +# Set daemons to run on boot.
    3.54 +sed_run_daemons()
    3.55 +{
    3.56 +	sed -i s/"RUN_DAEMONS=\"$RUN_DAEMONS\""/"RUN_DAEMONS=\"$NEW_DAEMONS\""/ \
    3.57 +		/etc/rcS.conf
    3.58 +}
    3.59 +
    3.60 +# Get user list
    3.61 +get_users()
    3.62 +{
    3.63 +	for i in `cat /etc/passwd | cut -d ":" -f 1`
    3.64 +	do
    3.65 +		if [ -d /home/$i ]; then
    3.66 +			login=$i
    3.67 +			uid=`cat /etc/passwd | grep $i | cut -d ":" -f 3`
    3.68 +			gid=`cat /etc/passwd | grep $i | cut -d ":" -f 4`
    3.69 +			name=`cat /etc/passwd | grep $i | cut -d ":" -f 5 | sed s/,,,//`
    3.70 +			home=`cat /etc/passwd | grep $i | cut -d ":" -f 6`
    3.71 +			shell=`cat /etc/passwd | grep $i | cut -d ":" -f 7`
    3.72 +			echo "$login | $uid:$gid | $name | $home | $shell"
    3.73 +		fi
    3.74 +	done
    3.75 +}
    3.76 +
    3.77 +# Remove a user or change passwd.
    3.78 +manage_user()
    3.79 +{
    3.80 +	export MANAGE_DIALOG="
    3.81 +<window title=\"Manage user: $USER\" icon-name=\"computer\">
    3.82 +	<vbox>
    3.83 +		<hbox>
    3.84 +			<text wrap=\"false\" width-chars=\"34\">
    3.85 +				<label>\"
    3.86 +Login name: $USER
    3.87 +				\"</label>
    3.88 +			</text>
    3.89 +		</hbox>
    3.90 +		<hbox>
    3.91 +			<text wrap=\"false\">
    3.92 +				<label>\"New password:\"</label>
    3.93 +			</text>
    3.94 +			<entry invisible_char=\"*\" visibility=\"false\">
    3.95 +				<variable>PASSWD</variable>
    3.96 +			</entry>
    3.97 +			<button>
    3.98 +				<label>Change</label>
    3.99 +				<input file icon=\"forward\"></input>
   3.100 +				<action>echo \"$USER:$PASSWD\" | chpasswd</action>
   3.101 +				<action type=\"closewindow\">MANAGE_USER</action>
   3.102 +			</button>
   3.103 +		</hbox>
   3.104 +		<hbox>
   3.105 +			<button>
   3.106 +				<label>Delete user</label>
   3.107 +				<input file icon=\"gtk-delete\"></input>
   3.108 +				<action>deluser $USER</action>
   3.109 +				<action type=\"closewindow\">MANAGE_USER</action>
   3.110 +			</button>
   3.111 +			<button cancel>
   3.112 +				<action type=\"closewindow\">MANAGE_USER</action>
   3.113 +			</button>
   3.114 +		</hbox>
   3.115 +	</vbox>
   3.116 +</window>
   3.117 +"
   3.118 +	gtkdialog --center --program=MANAGE_DIALOG >/dev/null
   3.119 +}
   3.120 +
   3.121 +# Add a new user.
   3.122 +add_user()
   3.123 +{
   3.124 +	export ADD_USER_DIALOG='
   3.125 +<window title="New user" icon-name="gtk-add">
   3.126 +	<vbox>
   3.127 +		<hbox>
   3.128 +			<text wrap="false" width-chars="34">
   3.129 +				<label>"
   3.130 +New account information
   3.131 +				"</label>
   3.132 +			</text>
   3.133 +		</hbox>
   3.134 +		<hbox>
   3.135 +			<text wrap="false">
   3.136 +				<label>"Login:      "</label>
   3.137 +			</text>
   3.138 +			<entry>
   3.139 +				<variable>NEW_USER</variable>
   3.140 +			</entry>
   3.141 +		</hbox>
   3.142 +		<hbox>
   3.143 +			<text wrap="false">
   3.144 +				<label>"Password:"</label>
   3.145 +			</text>
   3.146 +			<entry invisible_char="*" visibility="false">
   3.147 +				<variable>PASSWD</variable>
   3.148 +			</entry>
   3.149 +		</hbox>
   3.150 +		<hbox>
   3.151 +			<button ok>
   3.152 +				<action>adduser -D $NEW_USER</action>
   3.153 +				<action>echo "$NEW_USER:$PASSWD" | chpasswd</action>
   3.154 +				<action>adduser -G audio $NEW_USER</action>
   3.155 +				<action>rmdir /home/$NEW_USER</action>
   3.156 +				<action>cp -a /etc/skel /home/$NEW_USER</action>
   3.157 +				<action>cp /root/.xinitrc /home/$NEW_USER</action>
   3.158 +				<action>chown -R $NEW_USER:$NEW_USER /home/$NEW_USER</action>
   3.159 +				<action type="closewindow">MANAGE_USER</action>
   3.160 +			</button>
   3.161 +			<button cancel>
   3.162 +				<action type="closewindow">MANAGE_USER</action>
   3.163 +			</button>
   3.164 +		</hbox>
   3.165 +	</vbox>
   3.166 +</window>
   3.167 +'
   3.168 +	gtkdialog --center --program=ADD_USER_DIALOG >/dev/null	
   3.169 +}
   3.170 +
   3.171 +# Main dialog with notebook.
   3.172 +#
   3.173 +export MAIN_DIALOG='
   3.174 +<window title="SliTaz Control Box" icon-name="computer">
   3.175 +<vbox>
   3.176 +
   3.177 +	<hbox>
   3.178 +		<text use-markup="true">
   3.179 +			<label>"<b>SliTaz Control Box</b>"</label>
   3.180 +		</text>
   3.181 +		<pixmap>
   3.182 +			<input file>/usr/share/pixmaps/tazctrlbox.png</input>
   3.183 +		</pixmap>
   3.184 +	</hbox>
   3.185 +
   3.186 +	<notebook labels="System|Boot|Login|Users">
   3.187 +	
   3.188 +	<vbox>
   3.189 +		<frame Boxes panel>
   3.190 +			<hbox>
   3.191 +				<button>
   3.192 +					<label>Devices Manager</label>
   3.193 +					<input file icon="media-flash"></input>
   3.194 +					<action>mountbox &</action>
   3.195 +				</button>
   3.196 +				<button>
   3.197 +					<label>Network configuration</label>
   3.198 +					<input file icon="netbox"></input>
   3.199 +					<action>netbox &</action>
   3.200 +				</button>
   3.201 +				<button>
   3.202 +					<label>Packages Manager</label>
   3.203 +					<input file icon="tazpkg"></input>
   3.204 +					<action>tazpkgbox &</action>
   3.205 +				</button>
   3.206 +			</hbox>
   3.207 +		</frame>
   3.208 +		<frame Date and time>
   3.209 +			<hbox>
   3.210 +				<text wrap="false">
   3.211 +					<label>"Date:        "</label>
   3.212 +				</text>
   3.213 +				<entry editable="false" has_frame="false">
   3.214 +					<input>date</input>
   3.215 +					<variable>DATE</variable>
   3.216 +				</entry>
   3.217 +				<button>
   3.218 +					<label>Sync online</label>
   3.219 +					<input file icon="reload"></input>
   3.220 +					<action>rdate -s tick.greyware.com</action>
   3.221 +					<action>refresh:DATE</action>
   3.222 +				</button>
   3.223 +			</hbox>
   3.224 +			<hbox>
   3.225 +				<text wrap="true">
   3.226 +					<label>"Timezone:"</label>
   3.227 +				</text>
   3.228 +				<entry>
   3.229 +					<input>cat /etc/TZ</input>
   3.230 +					<variable>NEW_TZ</variable>
   3.231 +				</entry>
   3.232 +				<button>
   3.233 +					<label>Change</label>
   3.234 +					<input file icon="forward"></input>
   3.235 +					<action>echo "$NEW_TZ" > /etc/TZ</action>
   3.236 +				</button>
   3.237 +			</hbox>
   3.238 +		</frame>
   3.239 +	</vbox>'
   3.240 +# Boot
   3.241 +MAIN_DIALOG=${MAIN_DIALOG}"
   3.242 +	<vbox>
   3.243 +		<frame Grub boot loader>
   3.244 +			<hbox>
   3.245 +				<text wrap=\"false\">
   3.246 +					<label>\"Timeout:\"</label>
   3.247 +				</text>
   3.248 +				<entry>
   3.249 +					<input>cat /boot/grub/menu.lst | grep ^timeout | cut -d \" \" -f2</input>
   3.250 +					<variable>GRUB_TIMEOUT</variable>
   3.251 +				</entry>
   3.252 +				<button>
   3.253 +					<label>Change</label>
   3.254 +					<input file icon=\"forward\"></input>
   3.255 +					<action>$0 sed_grub_timeout</action>
   3.256 +				</button>
   3.257 +			</hbox>
   3.258 +			<hbox>
   3.259 +				<text wrap=\"false\">
   3.260 +					<label>\"Color:    \"</label>
   3.261 +				</text>
   3.262 +				<entry>
   3.263 +					<input>cat /boot/grub/menu.lst | grep ^color | cut -d \" \" -f2-3</input>
   3.264 +					<variable>GRUB_COLOR</variable>
   3.265 +				</entry>
   3.266 +				<button>
   3.267 +					<label>Change</label>
   3.268 +					<input file icon=\"forward\"></input>
   3.269 +					<action>$0 sed_grub_color</action>
   3.270 +				</button>
   3.271 +			</hbox>
   3.272 +			<hbox>
   3.273 +				<text wrap=\"false\">
   3.274 +					<label>\"Configuration file:\"</label>
   3.275 +				</text>
   3.276 +				<button>
   3.277 +					<label>/boot/grub/menu.lst</label>
   3.278 +					<input file icon=\"accessories-text-editor\"></input>
   3.279 +					<action>leafpad /boot/grub/menu.lst</action>
   3.280 +					<action>refresh:GRUB_COLOR</action>
   3.281 +					<action>refresh:GRUB_TIMEOUT</action>
   3.282 +				</button>
   3.283 +			</hbox>
   3.284 +		</frame>
   3.285 +		<frame rcS init scripts>
   3.286 +			<hbox>
   3.287 +				<text wrap=\"false\">
   3.288 +					<label>\"Check filesystems:\"</label>
   3.289 +				</text>
   3.290 +				<entry>
   3.291 +					<input>echo $CHECK_FS</input>
   3.292 +					<variable>NEW_CHECK_FS</variable>
   3.293 +				</entry>
   3.294 +				<button>
   3.295 +					<label>Change</label>
   3.296 +					<input file icon=\"forward\"></input>
   3.297 +					<action>$0 sed_check_fs</action>
   3.298 +				</button>
   3.299 +			</hbox>
   3.300 +			<hbox>
   3.301 +				<text wrap=\"false\">
   3.302 +					<label>\"Load modules:      \"</label>
   3.303 +				</text>
   3.304 +				<entry>
   3.305 +					<input>echo $LOAD_MODULES</input>
   3.306 +					<variable>NEW_MODULES</variable>
   3.307 +				</entry>
   3.308 +				<button>
   3.309 +					<label>Change</label>
   3.310 +					<input file icon=\"forward\"></input>
   3.311 +					<action>$0 sed_load_modules</action>
   3.312 +				</button>
   3.313 +			</hbox>
   3.314 +			<hbox>
   3.315 +				<text wrap=\"false\">
   3.316 +					<label>\"Run daemons:       \"</label>
   3.317 +				</text>
   3.318 +				<entry>
   3.319 +					<input>echo $RUN_DAEMONS</input>
   3.320 +					<variable>NEW_DAEMONS</variable>
   3.321 +				</entry>
   3.322 +				<button>
   3.323 +					<label>Change</label>
   3.324 +					<input file icon=\"forward\"></input>
   3.325 +					<action>$0 sed_run_daemons</action>
   3.326 +				</button>
   3.327 +			</hbox>
   3.328 +			<hbox>
   3.329 +				<text wrap=\"false\">
   3.330 +					<label>\"Add local comands:\"</label>
   3.331 +				</text>
   3.332 +				<button>
   3.333 +					<label>/etc/init.d/local.sh</label>
   3.334 +					<input file icon=\"accessories-text-editor\"></input>
   3.335 +					<action>leafpad /etc/init.d/local.sh</action>
   3.336 +				</button>
   3.337 +			</hbox>
   3.338 +		</frame>
   3.339 +	</vbox>"
   3.340 +# Login
   3.341 +MAIN_DIALOG=${MAIN_DIALOG}'
   3.342 +	<vbox>
   3.343 +		<frame Slim settings>
   3.344 +			<hbox>
   3.345 +				<text wrap="false">
   3.346 +					<label>"Sessions:     "</label>
   3.347 +				</text>
   3.348 +				<entry>
   3.349 +					<input>cat /etc/slim.conf | grep ^session | sed s/"sessions            "//</input>
   3.350 +					<variable>SLIM_SESSIONS</variable>
   3.351 +				</entry>
   3.352 +				<button>
   3.353 +					<label>Change</label>
   3.354 +					<input file icon="forward"></input>
   3.355 +					<action>sed -i "s/^sessions.*/sessions            $SLIM_SESSIONS/" /etc/slim.conf</action>
   3.356 +				</button>
   3.357 +			</hbox>
   3.358 +			<hbox>
   3.359 +				<text wrap="false">
   3.360 +					<label>"Default user: "</label>
   3.361 +				</text>
   3.362 +				<entry>
   3.363 +					<input>cat /etc/slim.conf | grep ^default_user | sed s/"default_user        "//</input>
   3.364 +					<variable>SLIM_DEF_USER</variable>
   3.365 +				</entry>
   3.366 +				<button>
   3.367 +					<label>Change</label>
   3.368 +					<input file icon="forward"></input>
   3.369 +					<action>sed -i "s/^default_user.*/default_user        $SLIM_DEF_USER/" /etc/slim.conf</action>
   3.370 +				</button>
   3.371 +			</hbox>
   3.372 +			<hbox>
   3.373 +				<text wrap="false">
   3.374 +					<label>"Theme:"</label>
   3.375 +				</text>
   3.376 +				<combobox>
   3.377 +					<variable>NEW_SLIM_THEME</variable>'
   3.378 +# List all installed Slim themes.
   3.379 +for dir in $(ls /usr/share/slim/themes)
   3.380 +do
   3.381 +	THEME_ITEMS="<item>$dir</item>"
   3.382 +	MAIN_DIALOG=${MAIN_DIALOG}${THEME_ITEMS}
   3.383 +done		
   3.384 +MAIN_DIALOG=${MAIN_DIALOG}'
   3.385 +				</combobox>	
   3.386 +				<button>
   3.387 +					<label>Preview</label>
   3.388 +					<input file icon="video-display"></input>
   3.389 +					<action>slim -p /usr/share/slim/themes/$NEW_SLIM_THEME &</action>
   3.390 +				</button>
   3.391 +				<button>
   3.392 +					<label>Change</label>
   3.393 +					<input file icon="forward"></input>
   3.394 +					<action>sed -i "s/^current_theme.*/current_theme       $NEW_SLIM_THEME/" /etc/slim.conf</action>
   3.395 +					<action>refresh:SLIM_THEME</action>
   3.396 +				</button>
   3.397 +			</hbox>
   3.398 +			<hbox>
   3.399 +				<text wrap="false">
   3.400 +					<label>"Configuration file:"</label>
   3.401 +				</text>
   3.402 +				<button>
   3.403 +					<label>/etc/slim.conf</label>
   3.404 +					<input file icon="accessories-text-editor"></input>
   3.405 +					<action>leafpad /etc/slim.conf</action>
   3.406 +					<action>refresh:SLIM_SESSIONS</action>
   3.407 +					<action>refresh:SLIM_DEF_USER</action>
   3.408 +				</button>
   3.409 +			</hbox>
   3.410 +		</frame>
   3.411 +	</vbox>'
   3.412 +# Display users list throught get_users.
   3.413 +MAIN_DIALOG=${MAIN_DIALOG}"
   3.414 +	<vbox>
   3.415 +		<tree>
   3.416 +			<width>650</width><height>300</height>
   3.417 +			<variable>USER</variable>
   3.418 +			<label>Login|uid:gid|Name|Home|SHell</label>
   3.419 +			<input>$0 get_users</input>
   3.420 +			<action>$0 manage_user</action>
   3.421 +			<action>refresh:USER</action>
   3.422 +		</tree>
   3.423 +		<hbox>
   3.424 +		<button>
   3.425 +			<label>Add newuser</label>
   3.426 +			<input file icon=\"gtk-add\"></input>
   3.427 +			<action>$0 add_user</action>
   3.428 +			<action>refresh:USER</action>
   3.429 +		</button>
   3.430 +	</hbox>
   3.431 +	</vbox>"
   3.432 +export MAIN_DIALOG=${MAIN_DIALOG}'	
   3.433 +	</notebook>
   3.434 +
   3.435 +	<hbox>
   3.436 +		<button>
   3.437 +			<label>Exit</label>
   3.438 +			<input file icon="exit"></input>
   3.439 +			<action type="exit">Exit</action>
   3.440 +		</button>
   3.441 +	</hbox>
   3.442 +
   3.443 +</vbox>
   3.444 +
   3.445 +</window>
   3.446 +'
   3.447 +
   3.448 +# Script can be called with an arg to exec a function.
   3.449 +if [ -n "$1" ]; then
   3.450 +	$1
   3.451 +else
   3.452 +	gtkdialog --center --program=MAIN_DIALOG >/dev/null
   3.453 +fi
   3.454 +
   3.455 +exit 0