#!/bin/bash

# wminfo plugin: displays the versions of the applications at SlackBuilds.org

# command: wminfo -p slackbuilds.wmi -c -b#666666 -f#ffffff

#
# CONFIGURATION SECTION BEGINS HERE
#

datafile="$HOME/.wminfo/.slackbuilds.tmp"

slackware_version=14.1

applications=" | \
    multimedia/flashplayer-plugin | \
    desktop/wmcube | \
    desktop/wminfo | \
    desktop/wmpower | \
    desktop/wmSunMoon | \
    "

#
# CONFIGURATION SECTION ENDS HERE
#

if [ ! -e $datafile ] || [ ! -s $datafile ] || [ "`find $datafile -mmin +3`" != "" ]
then
    ping -c1 slackbuilds.org > "$HOME/.wminfo/.slackbuilds.org" 2>&1
    if [ "`cat \"$HOME/.wminfo/.slackbuilds.org\" | grep 'unknown host'`" == "" ]
    then
	> $datafile
	for application in $applications
	do
	    lynx --source http://slackbuilds.org/repository/$slackware_version/$application/ | \
		grep '</h2>' | \
		sed -E 's/^ +//;s/ +/ /;s/<\/h2>//;s/[\(\)]//g' >> $datafile
	done
    fi
fi

cat $datafile
echo -e "         \n         \n         \n         \n         "

