#!/bin/bash
## exclude df/fs from conky --TEXT to work better with ver-1.10... ################
##################
##   qifsdf
## use it to show mountpoints and used/avail fs if the mounted and ##
## without tpm\|none\|shm\|devtmp\|tmpfs ##
## if yuo use df in conky direct, and plugin a media/usb/stick/card,
## then output df... will outgoing of screen-borders
#######################################################################################
## ${font Mono:size=10}${color9}${execpi 5 df -h --output=target,fstype,size,pcent,avail | grep -v "tpm\|none\|shm\|devtmp\|tmpfs"}

rm -f $HOME/tmp/fsdf.txt
rm -f $HOME/tmp/FSDF.txt
touch $HOME/tmp/FSDF.txt

df -H --output=target,fstype | grep -v "tpm\|none\|shm\|devtmp\|tmpfs" | grep "/" | cut -d" " -f1 > $HOME/tmp/fsdf.txt

echo 'Mounted on:  ${alignr}Type  Size ${fs_bar_free 8,60}  Free' >> $HOME/tmp/FSDF.txt

while read f
do

med=`echo $f | grep "media"`

if [ "$f" = "$med" ]; then
mist=`cat $HOME/tmp/FSDF.txt | grep "on /media :"`

if [ -z "$mist" ]; then

echo "on /media :" >> $HOME/tmp/FSDF.txt

fi

fff=`echo $f | cut -d"/" -f3`
# cut $fff to maximum of 15 chars with ~ and last 3
ffb=`echo $fff | awk '{print length($fff)}'`
ffc=`echo $fff | cut -c1-7`
ffd=`echo $fff | sed 's/.*\(.\{3\}\)$/\1/'`
ffa=`echo "~"`

if [ "$ffb" -gt "11" ]; then
ffx=`echo $ffc$ffa$ffd`
else
ffx=`echo $fff`
fi

# avail place
ffz=`df -H $f --output=avail | grep -v "[a-z]"`
toffx=`df -H --output=fstype,size $f | tail -1`
xffot=`df -H --output=avail $f | tail -1`
echo "$ffx"'${alignr}'	"$toffx"  '${fs_bar 8,60 '$f'}' "$xffot" >> $HOME/tmp/FSDF.txt

else

toffz=`df -H --output=fstype,size $f | tail -1`
zffot=`df -H --output=avail $f | tail -1`
echo "$f"'${alignr}'	"$toffz"  '${fs_bar 8,60 '$f'}' "$zffot" >> $HOME/tmp/FSDF.txt

fi

done < $HOME/tmp/fsdf.txt

cat $HOME/tmp/FSDF.txt

exit 0

