From 84ee451b94172148f82fdb1ed27ce71f1f1a0038 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Fri, 10 Jan 2014 06:37:17 +0100 Subject: [PATCH] Added some functions --- dpkg-frontend.sh | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/dpkg-frontend.sh b/dpkg-frontend.sh index da60bfd..b0ab8cb 100755 --- a/dpkg-frontend.sh +++ b/dpkg-frontend.sh @@ -60,19 +60,43 @@ print_help() } # Dialog for package searching -search() +search_pkg() { Search=`$Zenity --title "dpkg-frontend" --entry \ --text="Search for package"` $Dpkg --list | $Awk '{ print $2 }' | $Egrep -x $Search &> /dev/null if [ $? -eq 0 ]; then - Pkginfo=`$Dpkg --status $Search` - $Zenity --no-markup --title "dpkg-frontend" \ - --info --text="$Pkginfo" + return 0 + else + return 1 fi } +uninstall_pkg() +{ + #Pkginfo=`$Dpkg --status $Search` + $Zenity --title "dpkg-frontend" \ + --question \ + --text="Package $Search is installed.\nUninstall ${Search}?" + if [ $? -eq 0 ]; then # CHANGE NEXT LINE + sleep 5 | $Zenity --title "dpkg-frontend" \ + --progress --pulsate --text "Uninstalling ${Search}..." + fi +} + +install_pkg() +{ + echo "Install pkg?" +} + +show_selections() +{ + Selections=`dpkg --get-selections $Search | awk '{ print $2 }'` + $Zenity --title "dpkg-frontend" \ + --info --text "Selections for $Search is: ${Selections}" +} + # Create variables with absolute path to binaries and check # if we can execute it (binaries will be avaliable in # variables with first character uppercase, such as Grep) @@ -108,7 +132,12 @@ done ### Main ### -search +search_pkg +if [ $? -eq 0 ]; then + uninstall_pkg +fi + +show_selections echo $Search exit 0