From d981af59718d496081886d0d3ef55ebdcd400b85 Mon Sep 17 00:00:00 2001 From: Logandev_ Date: Fri, 20 Dec 2019 17:25:42 -0800 Subject: [PATCH] add pwnagotchi clock --- clock.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 clock.py diff --git a/clock.py b/clock.py new file mode 100644 index 0000000..a0828f6 --- /dev/null +++ b/clock.py @@ -0,0 +1,40 @@ +from pwnagotchi.ui.components import LabeledValue +from pwnagotchi.ui.view import BLACK +import pwnagotchi.ui.fonts as fonts +import pwnagotchi.plugins as plugins +import pwnagotchi +import logging +import datetime +import yaml + + +class PwnClock(plugins.Plugin): + __author__ = 'https://github.com/LoganMD' + __version__ = '1.0.2' + __license__ = 'GPL3' + __description__ = 'Clock/Calendar for pwnagotchi' + + def on_loaded(self): + logging.info("Pwnagotchi Clock Plugin loaded.") + + def on_ui_setup(self, ui): + memenable = False + with open('/etc/pwnagotchi/config.yml') as f: + data = yaml.load(f, Loader=yaml.FullLoader) + + if 'memtemp' in data["main"]["plugins"]: + if 'enabled' in data["main"]["plugins"]["memtemp"]: + if data["main"]["plugins"]["memtemp"]["enabled"]: + memenable = True + logging.info( + "Pwnagotchi Clock Plugin: memtemp is enabled") + if ui.is_waveshare_v2(): + pos = (130, 80) if memenable else (200, 80) + ui.add_element('clock', LabeledValue(color=BLACK, label='', value='-/-/-\n-:--', + position=pos, + label_font=fonts.Small, text_font=fonts.Small)) + + def on_ui_update(self, ui): + now = datetime.datetime.now() + time_rn = now.strftime("%m/%d/%y\n%I:%M%p") + ui.set('clock', time_rn)