-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathclock.py
More file actions
38 lines (33 loc) · 1.41 KB
/
clock.py
File metadata and controls
38 lines (33 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
class PwnClock(plugins.Plugin):
__author__ = 'originally https://github.com/LoganMD redone by NeonLightning'
__version__ = '1.0.3'
__license__ = 'GPL3'
__description__ = 'Clock/Calendar for pwnagotchi'
def on_loaded(self):
logging.info("Pwnagotchi Clock Plugin loaded.")
def on_ui_setup(self, ui):
pos1 = (100, 0)
ui.add_element('clock1', LabeledValue(color=BLACK, label='', value='-/-/-',
position=pos1,
label_font=fonts.Small, text_font=fonts.Small))
pos2 = (100,95)
ui.add_element('clock2', LabeledValue(color=BLACK, label='', value='-:--',
position=pos2,
label_font=fonts.Small, text_font=fonts.Small))
def on_ui_update(self, ui):
now = datetime.datetime.now()
datenow = now.strftime("%m/%d/%y")
timenow = now.strftime("%I:%M%p")
ui.set('clock1', datenow)
ui.set('clock2', timenow)
def on_unload(self, ui):
with ui._lock:
ui.remove_element('clock1')
ui.remove_element('clock2')