#!/bin/bash 
########################################################
# Find the fastest PCLinuxOS repository                #      
#                                                      #
#  © 2024 WTFPL lxgator@gmail.com                      #
########################################################
ICON="/usr/share/fastrepo/icons/fastrepo.png"
TIME=`cat /tmp/fastrepo/results|sed 's/\([^/]*\)\/\([^/]*\)\/\([^/]*\)\/\([^/]*\).*/\1\/\2\/\3\/\4/'`
rlist(){
while read data; do
echo "$data" 2>/dev/null
done | tee >(lisT)
}
function lisT(){
echo "$TIME"|yad --title='Fastest Repository' --list --columns=1 --rows=1 --column="Fastest Repository Results" --grid-lines=hor --text="" \
--center --width=450 --height=450 \
--window-icon="$ICON" --buttons-layout="center" --button="About"!/usr/share/fastrepo/icons/about.svg:5 \
--button="Cancel"!/usr/share/fastrepo/icons/cancel.svg:1 --button="Change"!/usr/share/fastrepo/icons/ok.svg:0 
if [ $? = "0" ]; then
exec "/usr/share/fastrepo/repo-select"
fi |
if [ $? = "5" ]; then
yad --width=475 --height=200 --center --text='                     \
<b>                              Fast Repo</b>\n                                         0.1.6 \n\nDisplays information to select the fastest repository\n\n© 2024 <b><a href="http://www.pclinuxos.com/">http://pclinuxos.com/</a></b> Community development\n' \
--window-icon=$ICON --fixed --center \
--image=$ICON \
--title='Fastest Repository' \
--button="Close"!/usr/share/fastrepo/icons/cancel.svg:1
fi
}
echo $TIME |sort | rlist | awk 'NR % 3 == 0;fflush()'  > /dev/null 2>&1  
