You are not logged in.

#1 2008-10-27 17:38:51

u_no_hu
Member
Registered: 2008-06-15
Posts: 453

Yet another Pacman front end in bash and zenity...

(Disclaimer: It was a boring day . Had nothing else to do... Stumbled upon zenity...started playing around with it ...after 4 hours a crappy frontend was ready)

Features:
1. search as you type. It is blazing fast
2. search as you type  So you can keep that mouse away
3. search as you type. Type the first letter and Enter for almost all the options. Esc goes to the previous screen
4. search as you type. Because it came as default with zenity .No coding was required

Install zenity if u want to try this out

#!/bin/sh
#           DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
#
#        Copyright (C) unohu 
#        Everyone is permitted to copy and distribute verbatim or modified
#        copies of this license document, and changing it is allowed as long
#        as the name is changed.
#
#           DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
#     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
#          0. You just DO WHAT THE FUCK YOU WANT TO.
#

term="urxvt"

main(){
    packagelist=$(pacman -Q)

    R=$(zenity --width=800\
           --height=600\
           --list\
            --text "Package Management"\
            --column "Option"\
            --column "Desc"\
            "Query"   "Installed package information"\
            "Sync"    "Install or update packages"\
            "Local Search"  "Search installed packages"\
            "Global Search"  "Search the sync db"\
    )

    if [ $? == 1 ]; then
        exit  1;
    fi

    case $R in
    "Query")
        Query;
        ;;
    "Sync")
        Sync;
        ;;
    "Local Search")
        Search "local" ;
        ;;
    "Global Search")
        Search "global" ;
        ;;
    esac
}



Search(){

    R=$(zenity --width=800\
           --height=600\
           --entry\
            --text "Search installed applications"\
    )

    if [ $? == 1 ] ; then
        main;
    fi

    searchstring=$R

    if [ $1 == "local" ]; then
        packagelist=$( pacman -Qqs $searchstring  );
    else
        packagelist=$( pacman -Sqs $searchstring  );
    fi

    if [ $1 == "local" ]; then
        ShowSearch "local" ;
    else
        ShowSearch "global" ;
    fi

    if [ $? == 1 ]; then
        Search $1;
    fi
}




ShowSearch(){

    R=$(zenity --width=800\
           --height=600\
           --list\
            --text "Select package"\
            --column "Package" \
             $packagelist \
    )

    if [ $? == 1 ];then
        return 1;
    fi

    packagename=$R

    if [ $1 == "local" ]; then
        ShowInfo $packagename "-Qi";
    else
        ShowInfo $packagename "-Si";
    fi

    if [ $? == 1 ];then
        ShowSearch $1;
    fi

}





Query(){
    R=$(zenity --width=800\
           --height=600\
           --list\
            --text "Select Query options"\
            --column "Option"\
            --column "Desc"\
            "Info" "View package information"\
            "List" "List the contents of the queried package"\
            "Dependencies" "List all packages installed as dependencie"\
            "Explicit" "List all packages explicitly installed"\
            "Orphans" "packages that were installed as dependencies but are no longer required by any installed package"\
            "Groups" "List all package groups  installed"\
            "Foreign" "List all manually installed foreign packages which are not in sync database"\
    )

    if [ $? == 1 ];then
        main;
    fi
 
    case $R in
    "Info")
        Info
        ;;
    "List")
        List
        ;;
    "Dependencies")
        Deps
        ;;
    "Orphans")
        Orphans;
        ;;
    "Explicit")
        Explicit;
        ;;
    "Groups")
        Groups;
        ;;
    "Foreign")
        Foreign;
        ;;
    esac

    if [ $? == 1 ];then
        Query;
    fi

}



Orphans(){
    ShowPackages "-Qdt"

    if [ $? == 1 ];then
        return 1;
    fi

    ShowInfo $packagename "-Qi"

    if [ $? == 1 ];then
        Orphans ;
    fi
}


Foreign(){
    ShowPackages "-Qm"

    if [ $? == 1 ];then
        return 1;
    fi

    ShowInfo $packagename "-Qi"

    if [ $? == 1 ];then
        Foreign ;
    fi
}



Deps(){
    ShowPackages "-Qd"

    if [ $? == 1 ];then
        return 1;
    fi

    ShowInfo $packagename "-Qi"

    if [ $? == 1 ];then
        Deps ;
    fi

}



Explicit(){
    ShowPackages "-Qe"

    if [ $? == 1 ];then
        return 1;
    fi

    ShowInfo $packagename "-Qi"

    if [ $? == 1 ];then
        Explicit ;
    fi

}



Groups(){

    grouplist=$( pacman -Qg  | cut -f1 -d " " | uniq )

    R=$(zenity --width=800\
           --height=600\
           --list\
            --text "Select Group"\
            --column "Group" \
             $grouplist \
    )

    if [ $? == 1 ];then
        return 1;
    fi

    groupname=$R

    ShowGroupMem $groupname

    if [ $? == 1 ];then
        Groups ;
    fi

}

ShowGroupMem(){

    packagelist=$(pacman -Qg  $1   | cut -f2 -d " " )
    R=$(zenity --width=800\
           --height=600\
           --list\
           --text "Select package"\
           --column "Package" \
            $packagelist \
    )

    if [ $? == 1 ];then
        return 1;
    fi

    packagename=$R

    ShowInfo $packagename "-Qi"

    if [ $? == 1 ];then
        ShowGroupMem $1 ;
    fi

}



ShowInfo()
{
    pacman $2  $1  >/tmp/result

    R=$(zenity --width=800\
           --height=600\
           --text-info\
           --filename="/tmp/result" \
    )

    if [ $? == 1 ];then
        return 1;
    fi

}


ShowPackages(){
    packagelist=$(pacman $1 )

    R=$(zenity --width=800\
           --height=600\
           --list\
            --text "Select package"\
            --column "Package" --column  "Version"\
             $packagelist \
    )

    if [ $? == 1 ];then
        return 1;
    fi

    packagename=$R

}

GetPackName(){
    R=$(zenity --width=800\
           --height=600\
           --list\
            --text "Select package"\
            --column "Package" --column  "Version"\
             $packagelist \
    )

    if [ $? == 1 ];then
        return 1;
    fi

    packagename=$R

}



Info(){
    param="-Qi"
    GetPackName

    if [ $? == 1 ];then
    return 1;
    fi
    ShowInfo $packagename $param

    if [ $? == 1 ];then
    Info;
    fi
}


List(){    
    param="-Ql"
    GetPackName

    if [ $? == 1 ];then
    return 1;
    fi

    ShowInfo $packagename $param

    if [ $? == 1 ];then
    List;
    fi
}


Sync(){
    R=$(zenity --width=800\
           --height=600\
           --list\
            --text "Select Sync  options"\
            --column "Option"\
            --column "Desc"\
            "Install" "Install or upgrade package"\
            "Syu" "You know what it is"\
    )

    if [ $? == 1 ];then
        main;
    fi
 
    case $R in
    "Syu")
        $term -e sudo pacman -Syu
        ;;
    "Install")
        Install;
        ;;
    esac

    if [ $? == 1 ];then
        Sync;
    fi
    
}

Install()
{
    packagelist=$( pacman -Ssq )
    R=$(zenity --width=800\
           --height=600\
           --list\
            --text "Package Name"\
            --column "Package"\
            $packagelist\
    )



    if [ $? == 1 ] ; then
        return 1;
    fi

    $term -e sudo pacman -S $R

}


main

(Disclaimer2: Bugs who come with bugfixes are allowed inside)


Don't be a HELP VAMPIRE. Please search before you ask.

Subscribe to The Arch Daily News.

Offline

Board footer

Powered by FluxBB