Originally Posted by
eshep
I finally was able to make my conky check for usb drives with variable mountpoints. Now no matter where a usb stick gets mounted as long as it is sda[1,2], it will show up with the right moutpoint displayed in conky. I'm sure this can be improved on, and if anyone can make it better, by all means, post it. Thanks to [tt]awk[/tt], everything works like I want it to. So far.
Highlights Include:
upload/download blocks change for wired or wireless
IP line also changes depending on wired/wifi state
power plug indicator green/red for in/out
sdb1 and sdb2 for usb disks displays correct variable mountpoint
disk usage update during copy not after transaction
I have this script that checks for any mounted file-system (including your root partition, separate home partition, etc.) Modified from a few sources in this thread.
Code:
#!/bin/bash
df -l | grep -vE ^tmpfs\|^udev\|^varrun\|^varlock\|^tmpfs\|^Filesystem | while read line ; do
device=`echo $line | awk '{ print $1 }'`
mount=`echo $line | sed 's|.*% \(.*\)|\1|'`
mountnospace=`echo $line | sed 's|.*% \(.*\)|\1|' | sed 's/ /\\\ /g'`
if mount | grep "on ${mountnospace} type" > /dev/null ; then
echo '${font dejavusansmono:size=8}$color1${fs_free_perc '$mount'}% free on '$mount'$alignr${diskio '$device'}/s
$color3${fs_bar 14 '$mount'}
$color1${voffset -18} '$device'$alignr${fs_used '$mount'}/${fs_size '$mount'} $font'
fi
done
df -l | grep -vE ^tmpfs\|^udev\|^varrun\|^varlock\|^tmpfs\|^Filesystem > /dev/null
if [ "$?" != "0" ]; then
echo '${voffset -12}'
fi
The difference between mount and mountnospace is that the latter has a backslash before the space, which is needed for the grep of the return from the mount command. The second if checks whether the script returns no drives and offsets a certain amount so that this doesn't leave an unsightly spacing in your conky. This is a leftover from a previous script which only checks for USB drives, where its common to have none at all, should not be necessary now but I leave it in just in case I make more modifications.
Of course, put it in your conky by:-
Code:
${execpi 6 /path/to/this/script}
Bookmarks