From 0aa4f95235a939862142cc9f6e65c5a2a500378d Mon Sep 17 00:00:00 2001 From: spees <speeskonijn@gmail.com> Date: Thu, 17 Oct 2019 23:55:11 +0200 Subject: [PATCH] Made the memtemp plugin usable and added to default.yml Signed-off-by: spees <speeskonijn@gmail.com> --- pwnagotchi/defaults.yml | 2 ++ pwnagotchi/plugins/default/memtemp.py | 28 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pwnagotchi/defaults.yml b/pwnagotchi/defaults.yml index e207f87..2308496 100644 --- a/pwnagotchi/defaults.yml +++ b/pwnagotchi/defaults.yml @@ -74,6 +74,8 @@ main: netmask: 24 interval: 1 # check every x minutes for device share_internet: false + memtemp: # Display memory usage and cpu temperature on screen + enabled: false # monitor interface to use iface: mon0 # command to run to bring the mon interface up in case it's not up already diff --git a/pwnagotchi/plugins/default/memtemp.py b/pwnagotchi/plugins/default/memtemp.py index 4ef823b..b17225a 100644 --- a/pwnagotchi/plugins/default/memtemp.py +++ b/pwnagotchi/plugins/default/memtemp.py @@ -2,8 +2,19 @@ # # totalmem usedmem freemem cputemp # +############################################################### +# +# Updated 18-10-2019 by spees <speeskonijn@gmail.com> +# - Changed the place where the data was displayed on screen +# - Made the data a bit more compact and easier to read +# - removed the label so we wont waste screen space +# - Updated version to 1.0.1 +# +############################################################### + + __author__ = 'https://github.com/xenDE' -__version__ = '1.0.0' +__version__ = '1.0.1' __name__ = 'memtemp' __license__ = 'GPL3' __description__ = 'A plugin that will add a memory and temperature indicator' @@ -21,9 +32,9 @@ class MEMTEMP: # set the minimum seconds before refresh the values refresh_wait = 30 - + refresh_ts_last = time.time() - refresh_wait - + def __init__(self): # only import when the module is loaded and enabled import os @@ -31,9 +42,9 @@ class MEMTEMP: def get_temp(self): try: temp = os.popen('/opt/vc/bin/vcgencmd measure_temp').readlines()[0].split('=')[1].replace("\n", '').replace("'","") - return 'cpu:' + temp + return 't:' + temp except: - return 'cpu:0.0C' + return 't:-' # cpu:37.4C def get_mem_info(self): @@ -42,9 +53,9 @@ class MEMTEMP: # total, used, free = map(int, os.popen('free -t -m').readlines()[-1].split()[1:]) # without Swap, only real memory: total, used, free = map(int, os.popen('free -t -m').readlines()[-3].split()[1:4]) - return "tm:"+str(total)+" um:"+str(used)+" fm:"+str(free) + return "\nT:"+str(total)+"M U:"+str(used)+"M\nF:"+str(free)+"M" except: - return "tm:0 um:0 fm:0" + return "\nT:- U:-\nF:- " # tm:532 um:82 fm:353 @@ -57,7 +68,7 @@ def on_loaded(): def on_ui_setup(ui): - ui.add_element('memtemp', LabeledValue(color=BLACK, label='SYS', value='tm:0 um:0 fm:0 0.0C', position=(0, ui.height()-28), + ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value='\nT:- U:-\nF:- -', position=(ui.width() / 2 + 17, ui.height() / 2), label_font=fonts.Bold, text_font=fonts.Medium)) @@ -66,3 +77,4 @@ def on_ui_update(ui): ui.set('memtemp', "%s %s" % (memtemp.get_mem_info(), memtemp.get_temp())) memtemp.refresh_ts_last = time.time() +