Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable custom time format for clock.py in config #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@

class PwnClock(plugins.Plugin):
__author__ = 'https://github.com/LoganMD'
__version__ = '1.0.2'
__version__ = '1.0.3'
__license__ = 'GPL3'
__description__ = 'Clock/Calendar for pwnagotchi'
__defaults__ = {
'enabled': False,
}

def on_loaded(self):
if 'date_format' in self.options:
self.date_format = self.options['date_format']
else:
self.date_format = "%m/%d/%y"

if 'time_format' in self.options:
self.time_format = self.options['time_format']
else:
self.time_format = "%I:%M %p"

logging.info("Pwnagotchi Clock Plugin loaded.")

def on_ui_setup(self, ui):
Expand All @@ -47,5 +55,5 @@ def on_ui_setup(self, ui):

def on_ui_update(self, ui):
now = datetime.datetime.now()
time_rn = now.strftime(self.date_format + "\n%I:%M %p")
time_rn = now.strftime(self.date_format + "\n" + self.time_format)
ui.set('clock', time_rn)
3 changes: 3 additions & 0 deletions clock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main.plugins.clock.enabled = "true"
main.plugins.clock.date_format = "%d/%m/%y"
main.plugins.clock.time_format = "%H:%M"