You have to choose a custom toolbar button, and you will see the free space (in gigabytes) as a label of it. If the free space on the drive is bigger than 999 GB, you will see the 999 in a green circle. It is possible for you to set a threshold. If the free space goes below this, a red circle will appear behind the number as an advance warning, which can be noticed quite easily and actually this is the main purpose of the script. By copying it into one of the "changing locations" of the CEA, the free space info on the button is refreshed on every folder change.
You have to set up your preferences in the first section of the code: the index of the button you use, the drive label you want to watch (empty means the current drive you are browsing on), and your desired threshold.
Code: Select all
//watch free space on a drive
// --- settings
$buttonindex=18; // the index of the custom toolbar button
$drivetowatch = "c:"; // empty is current
$threshold = 5; // in GB
// --- end of settings
$freespace = get("freespace",$drivetowatch,1)\(1024^3); //in GB
if ($freespace > 999) {
$labeltext = 999; //do not exceed the 3 characters in label
}
else {
$labeltext = $freespace;
}
$labeltext = $labeltext . strrepeat(" ", 3-strlen($labeltext)); //keep it in the middle with spaces at the end
if ($freespace < $threshold) {
$labeltext = $labeltext . "*#FF0000"; // red circle if we are below the threshold
}
elseif ($freespace > 999) {
$labeltext = $labeltext . "*#00FF00"; // if the free space is too big and above the threshold, draw a green circle
}
if ($drivetowatch == "") {
$drivetowatch = "the current drive"; // if no drive is set, write "current" into the tooltip
}
else {
$drivetowatch = "drive " . replace(recase($drivetowatch,"upper"),":","");
}
ctbname("Free space on $drivetowatch (in gigabytes)<crlf>Actual threshold is $threshold GB",$buttonindex);
ctbicon("label: " . $labeltext,$buttonindex);