diff --git a/src/stacer.js b/src/stacer.js index e528f893..78478652 100644 --- a/src/stacer.js +++ b/src/stacer.js @@ -9,40 +9,10 @@ const { spawn, spawnSync } = require('child_process') const prog = require('progressbar.js') const sudo = require('sudo-prompt') +var { prop, commands } = require('./src/config') require('./libs/fast-search') require('./libs/amaran.min') -var commands = -{ - aptCacheScanning: "/var/cache/apt/archives/", - crashReportsScanning : "/var/crash/", - systemLogsScanning: "/var/log/", - appCacheScanning: os.homedir() + "/.cache/", - autostartApps: os.homedir() + "/.config/autostart/", - getInstalledPackages: "dpkg --get-selections | cut -f1", - getAllService: "service --status-all | tr -d [*] | tr -d ' '", - removePackage: "apt-get remove --purge -y " -} - -/* - * Properties - */ -var prop = -{ - // Durations - networkBarsDuration: 600, - upBarDuration: 600, - cpuDuration: 1200, - memDuration: 1500, - diskDuration: 10000, - // Colors - netwrokBarColor: '#2bab51', - cpuBarColor: '#2bab51', - memBarColor: '#ff9939', - diskBarColor: '#dc175d', - trailColor: '#202b33' -} - var memInfo = "" var dTotal = "" var dUsed = "" @@ -188,7 +158,7 @@ function networkBars() }, step: function(state, bar) { - bar.setText(Math.abs(down).toString() + ' kb/s') + bar.setText(Math.abs(down).toString() + ' kB/s') } }); @@ -211,7 +181,7 @@ function networkBars() }, step: function(state, bar) { - bar.setText(Math.abs(up).toString() + ' kb/s') + bar.setText(Math.abs(up).toString() + ' kB/s') } }); @@ -224,15 +194,14 @@ function networkBars() { down = (data.rx_sec / 1024).toFixed(2) up = (data.tx_sec / 1024).toFixed(2) - downBar.animate(down / 1500) - upBar.animate(up / 1500) + downBar.animate(down / 2000) + upBar.animate(up / 2000) }) }, prop.networkBarsDuration); } function systemInformationBars() { - /* * Create the circle bars */ @@ -250,13 +219,19 @@ function systemInformationBars() /* * Memory value setter */ + function prettySize( size ){ + return ( size / ( Math.pow(1024, 3) ) ).toFixed(2) + } + setInterval( function() { - si.mem( ( ram ) => { - var usedMem = new Number( ram.available ) - var totalMem = new Number( ram.used ) + si.mem( ( ram ) => + { + var usedMem = ram.total - ram.available + var totalMem = ram.total + - memInfo = (usedMem / 1000000000 ).toFixed(2) + '/' + (totalMem / 1000000000 ).toFixed(2) + "GB" + memInfo = prettySize(usedMem) + ' / ' + prettySize(totalMem) + "GB" memBar.animate(usedMem / totalMem) }) @@ -270,9 +245,9 @@ function systemInformationBars() diskspace.check('/', function(err, total, free, status) { var used = total-free - dTotal = (total / 1000000000).toFixed(2) + "GB" - dUsed = (used / 1000000000).toFixed(2) + "GB" - diskBar.animate(used / total); + dUsed = (used / 1000000000).toFixed(1) + dTotal = (total / 1000000000).toFixed(1) + "GB" + diskBar.animate( used / total ); }); } diskInfo() @@ -285,7 +260,7 @@ function systemInformationBars() $(".system-info ul").append($("