From 77b6009349efdb47cdccb6b93004a32bdf03ae4e Mon Sep 17 00:00:00 2001 From: xenDE Date: Thu, 3 Oct 2019 18:11:42 +0200 Subject: [PATCH 1/3] plugin for add memory infos and cpu temperature to screen think this should be in default, but disabled --- .../pwnagotchi/plugins/default/memtemp.py | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py new file mode 100644 index 0000000..5ebc38c --- /dev/null +++ b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py @@ -0,0 +1,55 @@ +# tempmem shows memory infos and cpu temperature +# +# totalmem usedmem freemem cputemp +# +__author__ = 'https://github.com/xenDE' +__version__ = '1.0.0' +__name__ = 'memtemp' +__license__ = 'GPL3' +__description__ = 'A plugin that will add a memory and temperature indicator' +__enabled__ = False + +import struct + +from pwnagotchi.ui.components import LabeledValue +from pwnagotchi.ui.view import BLACK +import pwnagotchi.ui.fonts as fonts + + +class MEMTEMP: + def __init__(self): + # only import when the module is loaded and enabled + import os + + def get_temp(self): + try: + temp = os.popen('/opt/vc/bin/vcgencmd measure_temp').readlines()[0].split('=')[1].replace("\n", '').replace("'","") + return 'cpu:' + temp + except: + return 'cpu:0.0C' + # cpu:37.4C + + def get_mem_info(self): + try: + total, used, free = map(int, os.popen('free -t -m').readlines()[-1].split()[1:]) + return "tm:"+str(total)+" um:"+str(used)+" fm:"+str(free) + except: + return "tm:0 um:0 fm:0" + # tm:532 um:82 fm:353 + + +memtemp = None + + +def on_loaded(): + global memtemp + memtemp = MEMTEMP() + + +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), + label_font=fonts.Bold, text_font=fonts.Medium)) + + +def on_ui_update(ui): + ui.set('memtemp', "%s %s" % (memtemp.get_mem_info(), memtemp.get_temp())) From fcd3ae650a244750448b203ea0468751eb530673 Mon Sep 17 00:00:00 2001 From: xenDE Date: Thu, 3 Oct 2019 18:46:46 +0200 Subject: [PATCH 2/3] =?UTF-8?q?eine=20configurierbare=20wartezeit=20hinzug?= =?UTF-8?q?ef=C3=BCgt,=20bevor=20die=20werte=20aktualisiert=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to protect the display lifetime --- .../scripts/pwnagotchi/plugins/default/memtemp.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py index 5ebc38c..85a4552 100644 --- a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py +++ b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py @@ -7,7 +7,7 @@ __version__ = '1.0.0' __name__ = 'memtemp' __license__ = 'GPL3' __description__ = 'A plugin that will add a memory and temperature indicator' -__enabled__ = False +__enabled__ = True import struct @@ -15,8 +15,16 @@ from pwnagotchi.ui.components import LabeledValue from pwnagotchi.ui.view import BLACK import pwnagotchi.ui.fonts as fonts +import time + 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 @@ -52,4 +60,7 @@ def on_ui_setup(ui): def on_ui_update(ui): - ui.set('memtemp', "%s %s" % (memtemp.get_mem_info(), memtemp.get_temp())) + if time.time() > memtemp.refresh_ts_last + memtemp.refresh_wait: + ui.set('memtemp', "%s %s" % (memtemp.get_mem_info(), memtemp.get_temp())) + memtemp.refresh_ts_last = time.time() + From 9b5a12bd0cf5225900eb154001675c30ca1ca44e Mon Sep 17 00:00:00 2001 From: xenDE Date: Thu, 3 Oct 2019 18:52:38 +0200 Subject: [PATCH 3/3] default: disable the plugin --- .../pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py index 85a4552..43c64c6 100644 --- a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py +++ b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py @@ -7,7 +7,7 @@ __version__ = '1.0.0' __name__ = 'memtemp' __license__ = 'GPL3' __description__ = 'A plugin that will add a memory and temperature indicator' -__enabled__ = True +__enabled__ = False import struct