#!/bin/bash

# wminfo plugin: informs about new Slackware patches

# command: wminfo -p slackware-patches.wmi -b#d3d3d3 -f#000000

# That plugin uses the same mirror you enabled in /etc/slackpkg/mirrors
# file.  It looks for Slackware patches and stores the data in
# $HOME/.wminfo/.patches.tmp file.  Finally it displays the information
# about the available patches.

MIRROR="`cat /etc/slackpkg/mirrors 2> /dev/null | grep -v '^#'`"

if [ "$MIRROR" == "" ]
then
    echo "slackware-patches.wmi: none Slackware mirror defined in /etc/slackpkg/mirrors file."
    echo -e "         \n         \n         \n         \n"
    exit
fi

tempfile="$HOME/.wminfo/.slackware-patches.tmp"

lynx --source ${MIRROR}patches/packages/ | \
grep .txz | grep -v .asc | grep HREF | sed 's/.*packages\///;s/"//' > $tempfile
ls /var/cache/packages/patches/packages/ | grep -v .asc >> $tempfile
ls /var/cache/packages/patches/packages/ | grep -v .asc >> $tempfile

cat $tempfile | sort | uniq -u
echo -e "         \n         \n         \n         \n         "

