The time now is Mon 20 May 2013, 00:20
All times are UTC - 4 |
| Author |
Message |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Sat 02 Feb 2013, 18:05 Post subject:
ROX-Desktop drive icons: show free space in tooltips |
|
Ok, so today I definitively got tired of necessity to launch Pmount (or go to /mnt, terminal or wherever) every time I want to check free space on my drives.
Anyone tired either? Here's the "cure":
| Code: | #!/bin/bash
INFO_PATH=/root/.pup_event
while true; do
df -h | grep -vE "/dev/loop|tmpfs|unionfs|shmfs" | 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"`
NEW_LINE="`echo ${LINE%%Size: *}`$SIZE</Summary>"
if [ "$LINE" != "$NEW_LINE" ]; then
sed -i 's|'"$LINE"'|'"$NEW_LINE"'|' "$INFO_PATH/$NAME/AppInfo.xml"
fi
done
sleep 5
done |
This short script updates periodically (5 sec.) tooltips for ROX drive icons, by adding current amount of available space.
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
EDIT: Correction in code.
_________
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!
 |
| Description |
|
| Filesize |
25.64 KB |
| Viewed |
319 Time(s) |

|
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Last edited by SFR on Sun 03 Feb 2013, 07:13; edited 2 times in total
|
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1229 Location: Ukraine
|
Posted: Sat 02 Feb 2013, 18:40 Post subject:
|
|
Dear SFR,
What a nice, useful and simple idea. It workes nicely under Lucid, too.
Thanks.
With kind regards,
vovchik
|
|
Back to top
|
|
 |
rhadon

Joined: 27 Mar 2008 Posts: 1228 Location: Germany
|
Posted: Sun 03 Feb 2013, 05:02 Post subject:
|
|
Hi SFR,
tried your program, but no success . I also use Slacko 5.4, with and without save file.
I allways get:
| Code: | | sed: -e expression #1, char 54: unknown option to `s' |
added echo's to see the variables, so I think, it's the last sed command:
| Code: | # ./freespace
NAME=drive_sda5
SIZE= Size: 14G Free: 583M
LINE= <Summary>Filesystem: ext3 Size: 13,9GB</Summary>
NEW_LINE=<Summary>Filesystem: ext3 Size: 14G Free: 583M</Summary>
sed: -e expression #1, char 54: unknown option to `s' |
Any idea?
Rolf
_________________ Ich verwende "frugal", und das ist gut so.
Raspberry Pi without Puppy? No, thanks.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Sun 03 Feb 2013, 06:09 Post subject:
|
|
Thanks for the info, Vovchik!
Rhadon, yes! I think I see what went wrong.
It's decimal comma separator in "13,9GB" and I also used comma as a separator in the second 'sed' (I have left my "Country Settings" default - English, i.e. dot as separator).
Ok, I corrected the code, how about now?
Thanks for spotting this, btw.
PS. Rolf, maybe this is also the reason why <spinbutton> doesn't work for you when floating point values are in use..?
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
rhadon

Joined: 27 Mar 2008 Posts: 1228 Location: Germany
|
Posted: Sun 03 Feb 2013, 06:42 Post subject:
|
|
Great! It works fine now.
And it's much more comfortable than using pmount or partview.
Thanks for sharing,
Rolf
Will test spinbuttons with english country settings soon .
Edit: Yes. Again, your'e right. Spinbutton and bdraw 1.6 are working fine with english country settings.
_________________ Ich verwende "frugal", und das ist gut so.
Raspberry Pi without Puppy? No, thanks.
|
|
Back to top
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|