From 56ba560f4ef74c881a6b856597940364a5824ae0 Mon Sep 17 00:00:00 2001 From: Michael Antonacci Date: Tue, 10 Mar 2015 00:03:27 -0400 Subject: [PATCH 1/2] fix negative RAM issue no need to calculate used ram anymore, just read from 'free -m' --- archey | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/archey b/archey index 5f3a1a1..9a8d1c0 100755 --- a/archey +++ b/archey @@ -212,14 +212,15 @@ class RAM: def __init__(self): raminfo = Popen(['free', '-m'], stdout=PIPE).communicate()[0].decode('Utf-8').split('\n') ram = ''.join(filter(re.compile('M').search, raminfo)).split() - used = int(ram[2]) - int(ram[5]) - int(ram[6]) - usedpercent = ((float(used) / float(ram[1])) * 100) + used = int(ram[2]) + total = ram[1] + usedpercent = ((float(used) / float(total)) * 100) if usedpercent <= 33: - ramdisplay = '%s%s MB %s/ %s MB' % (colorDict['Sensors'][1], used, colorDict['Clear'][0], ram[1]) + ramdisplay = '%s%s MB %s/ %s MB' % (colorDict['Sensors'][1], used, colorDict['Clear'][0], total) if usedpercent > 33 and usedpercent < 67: - ramdisplay = '%s%s MB %s/ %s MB' % (colorDict['Sensors'][2], used, colorDict['Clear'][0], ram[1]) + ramdisplay = '%s%s MB %s/ %s MB' % (colorDict['Sensors'][2], used, colorDict['Clear'][0], total) if usedpercent >= 67: - ramdisplay = '%s%s MB %s/ %s MB' % (colorDict['Sensors'][0], used, colorDict['Clear'][0], ram[1]) + ramdisplay = '%s%s MB %s/ %s MB' % (colorDict['Sensors'][0], used, colorDict['Clear'][0], total) self.key = 'RAM' self.value = ramdisplay From d671a4a71d79a6e2eaa7ca86543d8b483116bd84 Mon Sep 17 00:00:00 2001 From: Michael Antonacci Date: Fri, 13 Mar 2015 18:22:03 -0600 Subject: [PATCH 2/2] remove unnecessary conversion to int --- archey | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archey b/archey index 9a8d1c0..9372267 100755 --- a/archey +++ b/archey @@ -212,7 +212,7 @@ class RAM: def __init__(self): raminfo = Popen(['free', '-m'], stdout=PIPE).communicate()[0].decode('Utf-8').split('\n') ram = ''.join(filter(re.compile('M').search, raminfo)).split() - used = int(ram[2]) + used = ram[2] total = ram[1] usedpercent = ((float(used) / float(total)) * 100) if usedpercent <= 33: