#!/bin/bash
module_info="Icon helper"
icons_help() {
    echo "update: Update icon cache"
    echo "install: install icon theme from zip"
}
icons_update(){
   path="$HOME/.icons/"
    if is_root
    then
        path="/usr/share/icons/"
    fi
    for theme in $(ls $path)
    do
        if [ -d $path/$theme ]
        then
            echo -e "\033[32;1mUpdating for \033[;0m$theme"
            gtk-update-icon-cache -t -f $path/$theme
        fi
    done
}
icons_install(){
    path="$HOME/.icons/"
    if is_root
    then
        path="/usr/share/icons/"
    fi
echo $3
    if [ -f "$3" ]
    then
        tempdir=$(mktemp)
        rm -rf $tempdir
        mkdir -p $tempdir
        cp -prf $3  $tempdir/icons
        cd $tempdir
        tar -xf icons
        `find $tempdir | grep "index.theme" | sed "s|index.theme| $path|g" | sed "s/^/cp -prf /g"` 2> /dev/null
        icons_update
    fi
}

