[Debian-NP-Commits] r183 - people/zufus/dialog

Marco Presi debian-np-devel@lists.alioth.debian.org
Fri, 30 Jul 2004 13:32:31 -0600


Author: zufus
Date: Fri Jul 30 13:32:31 2004
New Revision: 183

Added:
   people/zufus/dialog/
   people/zufus/dialog/functions
Log:
some functions to implement debian-np configuration tool


Added: people/zufus/dialog/functions
==============================================================================
--- (empty file)
+++ people/zufus/dialog/functions	Fri Jul 30 13:32:31 2004
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+# A dialog based interface to configure debian-np-packages
+
+# Copyright (C) 2003 Debian-NP team (Bagunca people) <debian-np-devel#lists.alioth.debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# On Debian GNU/Linux systems, the complete text of the GNU General
+# Public License can be found in `/usr/share/common-licenses/GPL'.
+
+# Adapted by Marco Presi (Zufus) <zufus@debian.org> from examples taken from Debian dialog 
+  package
+
+set -e
+
+: ${DIALOG=dialog}
+
+tempfile=`/tmp/tempfile 2> /dev/null` || tempfile=/tmp/test$$
+trap "rm -f $tempfile" 0 1 2 5 9 15
+
+_read_installed_np_packages ()
+{
+    COLUMNS=400 && dpkg -l "*-np-*" | grep ii | awk '{ print $2 }';
+}
+
+_build_menu ()
+{
+    MENU=""
+    for i in $(_read_installed_np_packages); do
+	short_desc=$(apt-cache show $i |grep Desc | awk -F ': ' '{ print $2 }')
+	MENU=$MENU"\t\"$i\"\t \"$short_desc\"\n"
+    done
+
+}
+
+_launch_menu ()
+{
+    MENU_STRING="Welcome to Debian-NP configuration Center. \n\
+Here you can run conf scripts of Debian-NP tasks \n\
+that you have installed.\n\
+             Select task to configure:"
+
+    $DIALOG --clear --help-button --item-help --title "MENU BOX" \
+           --menu $MENU_STRING 20 51 4 \
+	 "pippo" "pippo"  2> $tempfile
+
+retval=$?
+
+choice=`cat $tempfile`
+
+case $retval in
+  0)
+    echo "'$choice' chosen.";;
+  1)
+    echo "Cancel pressed.";;
+  255)
+    echo "ESC pressed.";;
+esac
+
+
+}
+
+
+_build_menu
+_launch_menu $MENU