I have modified the following script to show how much the home folder is using:
WindowTitle {FvwmApplet-splinux}
WindowSize 68 24 # Taille
Font "Shadow=1:xft:Verdana:bold:pixelsize=12:minspace=true"
Init
Begin
Set $sp = Res: (GetOutput {exec du -h -s ~| awk '{print $1}'} 1 -1)
ChangeTitle 1 $sp
End
PeriodicTasks
Begin
If (RemainderOfDiv (GetTime) 5)==0 Then
Begin
Set $sp = Res: (GetOutput {exec du -h -s ~| awk '{print $1}'} 1 -1)
ChangeTitle 1 $sp
End
End
Widget 1
Property
Size 68 24
Position 0 0
Colorset 60
Font "Shadow=1:xft:Verdana:pixelsize=11:minspace=true"
Flags Left
Type ItemDraw
Title {}
End
Originally the script used the ‘read’ command but the system that I am running this script on does not have that command.
But the above script does not output anything, any hints to what I am doing wrong?
Btw is there someway to subtract the result from a number. Lets say that the result is 30 M and I have 40 M capacity then I would like to subtract y from 40 before printing the result.
thought of something like:
sh -c 'du -h -s ~ | ( read 40 -y x ; echo " $y" )'
but it seems that its no as simple. Is even possible?
There is, and this now just becomes shell-mechanics. So, assuming you know the capacity overall you can do:
cap=40
Then in your script:
sh -c 'cap=40; du -s /somewhere | (read x y; echo " $((cap - x))")'
Of course, ascertaining the value of the overall capacity can be done with ‘df’ if you wish – assuming the directory being df’d was a partition, and existed on one (that you could ascertain).
No, I really meant “x” – that’s the numerical part of the output (look at the example in my last post. It’s not consistent with your variable assignage, but hey – I am sure even you have the notion enough to transpose them.)
Look again at my example. “-h” is only ever useful when you’re dealing with humans (hence the reason it’s “human-readable”.) Omit the ‘-h’ flag, and you’ll get the raw number (again, as per my example).