Anyone tired either?

Code: Select all
#!/bin/bash
INFO_PATH=/root/.pup_event
while true; do
df -h | grep -vE "/dev/loop|tmpfs|unionfs|shmfs|truecrypt" | grep "/mnt" | sed 's|/dev/|drive_|g' | awk '{print $1"| Size: "$2" Free: "$4}' | \
while read i; do
NAME="${i%%|*}"
SIZE="${i##*|}"
LINE=`grep "<Summary>" "$INFO_PATH/$NAME/AppInfo.xml" 2>/dev/null`
NEW_LINE="`echo ${LINE%%Size: *}`$SIZE</Summary>"
if [ "$LINE" != "$NEW_LINE" ] && [ ! "$(pidof snapmergepuppy)" ]; then
#sed -i 's|'"$LINE"'|'"$NEW_LINE"'|' "$INFO_PATH/$NAME/AppInfo.xml"
cat "$INFO_PATH/$NAME/AppInfo.xml" | sed -e 's|'"$LINE"'|'"$NEW_LINE"'|' > /tmp/roxdrvfreespace_temp
mv -f /tmp/roxdrvfreespace_temp "$INFO_PATH/$NAME/AppInfo.xml"
fi
done
sleep 5
done
I used 'dh -h' which rounds up the size, but it's sufficient to get overall insight.
That's it. Barely tested (only in Slacko-5.4), but so far works fine with internal and external (USB) drives. YMMV, of course.
BTW, if a drive will be unmounted, the tooltip won't be updated anymore (until mounted again) and its recent "Free: ..." value remains there.
This may be considered as a downside, but I don't mind that it's that way (and the code is much more simple).
If one try it and think "nah, I don't like it":
1. Kill the script
2. Delete everything from /root/.pup_event/ dir
3. Restart X
_________
WARNING: I have noticed that if I copy/paste the code using Opera browser, it (Opera) has unpleasant habit of adding leading and trailing spaces to pasted text.
So if it will happen, make sure that this line:
df -h | grep -vE "/dev/loop|tmpfs|unionfs|shmfs" | grep "/mnt" | sed 's|/dev/|drive_|g' | awk '{print $1"| Size: "$2" Free: "$4}' | \
doesn't contain any extra space after \ or else script won't work.
Enjoy & Greetings!