Muximux
Muximux copied to clipboard
[Add-on] Diskspace Monitor Tab Add-on Version 1.00 final for Muximux
I think it will be useful... refresh every 30 mins or 1 hour. like this free space "27GB / 40GB" possible if you prefer style you can use progress bar with CSS style =)
credits by Darian Brown (http://www.thecave.info/) and modified by me.

version 1.00 final released! =)
Looking for code? Please look below.
People who want this are free to add it, so I wont close the issue for the time being - however, this is beyong the scope of Muximux itself so it will most likely not be included in the official repo.
ok this is like add-on for muximux =)
I've a little issue:
Why I've a scrollbar ? :(
@monsieurpouet > same problem here: https://github.com/mescon/Muximux/issues/49
SOLUTION: find <nav> then replace with <nav style='overflow-y: hidden;'> in muximux.php
Great news! very soon to update code with click to refresh on it =)
It must put ' instead of ". If not, this don't work.
Like that:
Thanks for your answer :)
@monsieurpouet oops.. sorry =) i made code without testing.... I'm glad you like this feature.
Great news! very soon to update code with click to refresh on it =)
@alienx2 Thanks for your contribution to this project. Did you find a way to refresh the disk space information with a click?
@judhat2... yes im completed script for click to refresh but im about to release final version with 3 mode: timer, click and regular and i'm making easy to install this feature for everyone. stay tuned! =)
Thanks, good to hear!
Diskspace Monitor Add-on for Muximux Version 1.00 final
copy and paste code to notepad and save it as "diskspace.php" to where muximux installed folder.
How to Install?
(2 Steps only) Edit index.php with any code editor or notepad and following:
-
Add this line after "
require 'muximux.php';":require('diskspace.php'); -
Insert this line to
<head> </head>:<?php echo insertscript('install'); ?>
Added Features:
- Mode: Click, Timer, Normal
- Text format
- Easy to Install for everyone. Just 2 lines only
- Easy to config
<?php
##########################################################
##########################################################
// Created by AlienX2 //
##########################################################
##########################################################
####### HOW TO INSTALL ###################################
# * Add to index.php after "require 'muximux.php';": #
# require('diskspace.php'); #
# #
# * Add to index.php in <head> </head>: #
/* <?php echo insertscript('install'); ?> */
# #
##########################################################
##########################################################
###### SETTINGS ##########################################
#
# // 'click' = click to refresh;
# // 'time' = refresh per time;
# // 'none' = nothing, just reload page.
$mode = 'none';
#
# // 'percent' = percent of how big used of space;
# // 'ut' = Used space / Total Space;
# // 'ft' = Free space / Total Space;
# // 'free' = Free space of size;
$textbar_type = 'ft';
#
# // Required: $mode='time';
# // xxxx seconds
# // e.g. '60' seconds = 1 minute; '300' seconds = 5 mins; '900' seconds = 15mins;
$time = '5';
#
# // drive path in '' . e.g. 'd:/' or '/mnt/DownloadHDD'
$monitor_path = '/mnt/LinuxHOME';
#
##########################################################
if(isset($_GET['diskspace'])) {
echo progressbar('update');
//echo 'hello';
return;
}
if(isset($_GET['percentofspace'])) {
echo progressbar('dp').'%';
return;
}
if(isset($_GET['html'])) {
echo progressbar('html');
return;
}
function insertscript($type) {
global $mode;
global $time;
if($type=='install') {
$insertcode = "<script src='//code.jquery.com/jquery-1.12.0.min.js'></script><style type='text/css'>
.diskspace {
height:35px;
float: right !important;
margin-right: 5px;
margin-top: 3px;
}
.progress {
/* background: #747B8B;*/
background:none;
border: 2px solid #747B8B;
height: 32px;
width: 120px;
}
.progress .prgbar {
position: relative;
height: 32px;
z-index: 999;
}
.prgbar {
background:#f5f5f5 !important;
}
.progress .prgtext {
color: gray;
text-align: center;
font-size: 13px;
padding: 6px 0 0;
width: 120px;
position: absolute;
z-index: 1000;
text-shadow: 1px 1px #747B8B;
}
.progress .prginfo {
margin: 3px 0;
}
</style>
";
if ($mode == 'time') {
$insertcode .= "
<script>
$(document).ready(function() {
$('".'<li class="diskspace" style="cursor:default !important;"></li>'."').insertBefore( 'ul.cd-tabs-navigation nav li:last-child' );
$.get('diskspace.php?html', function(data){
$('li.diskspace').html(data);
});
$.get('diskspace.php?percentofspace', function(data){
$('.progress .prgbar').width(data);
});
});
</script>
<script>
var refresh = setInterval(
function (){
$.get('diskspace.php?percentofspace', function(data){
$('.progress .prgbar').width(data);
});
$.get('diskspace.php?percentofspace', function(data){
$('.progress .prgbar').width(data);
});
$('div.prgtext').load('diskspace.php?diskspace');
}, ".convertmilliseconds($time).");
</script>
";
} else if ($mode == 'click') {
$insertcode .= "<script>
$(document).ready(function() {
$('".'<li class="diskspace"></li>'."').insertBefore( 'ul.cd-tabs-navigation nav li:last-child' );
$.get('diskspace.php?html', function(data){
$('li.diskspace').html(data);
});
$.get('diskspace.php?percentofspace', function(data){
$('.progress .prgbar').width(data);
});
$('.diskspace').click(function() {
$.get('diskspace.php?percentofspace', function(data){
$('.progress .prgbar').width(data);
});
$('.diskspace div.prgtext').load('diskspace.php?diskspace');
});
});
</script>";
} else { $insertcode .= "<script>
$(document).ready(function() {
$('".'<li class="diskspace" style="cursor:default !important;"></li>'."').insertBefore( 'ul.cd-tabs-navigation nav li:last-child' );
$.get('diskspace.php?html', function(data){
$('li.diskspace').html(data);
});
$.get('diskspace.php?percentofspace', function(data){
$('.progress .prgbar').width(data);
});
});
</script>
"; }
return $insertcode;
}
}
function convertmilliseconds ($seconds) {
return $seconds * 1000;
}
function progressbar($request = '') {
global $monitor_path;
global $textbar_type;
$dfree = disk_free_space($monitor_path);
$dt = disk_total_space($monitor_path);
$du = $dt - $dfree;
$dp = sprintf('%.2f',($du / $dt) * 100);
$df = HumanSize($dfree);
$dt = HumanSize($dt);
$du = HumanSize($du);
if($textbar_type == 'percent') {
$data = $dp.' %';
} else if($textbar_type == 'ut') {
$data = $du." / ".$dt;
} else if($textbar_type == 'ft') {
$data = $df." / ".$dt;
} else if($textbar_type == 'free') {
$data = HumanSize($dfree, 2).' left';
} else {
$data = 'ERROR: $textbar_type is missing!';
}
if($request == 'dp') {
return $dp;
} else if ($request == "update") {
return $data;
//return $df .'/'. $dt;
} else if ($request == "html") {
return
'<div class="progress">
<div class="prgtext">'.$data.'</div><div class="prgbar"></div><div class="prginfo">
</div></div>';
}
}
function HumanSize($bytes, $digit = 1)
{
$types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
return( round( $bytes, $digit ) . " " . $types[$i] );
}
?>
@judhat2 @monsieurpouet i just release code. Grab it =) Don't forget to install fresh muximux.
@alienx2 Nice job! FYI, you're inserting an instance of jQuery, when Muximux itself already loads jQuery. This creates a javascript conflict, so perhaps you could make it work with the bundled jquery version?
@mescon Thanks =) and i tried tested it not working without add jQuery. that's why i added.
@mescon i found you put jquery in index.php but very bottom instead of put in <head></head>... it didnt work with my code? even also jquery wont work?
@alienx2 All javascript is at the bottom for performance reasons. Read more here: https://developer.yahoo.com/performance/rules.html#js_bottom=