2016-10-31 14:39:52 +01:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-10-30 17:30:09 +01:00
|
|
|
import datetime
|
2016-10-30 17:56:04 +01:00
|
|
|
import bumblebee.module
|
|
|
|
|
2016-10-31 16:08:03 +01:00
|
|
|
def usage():
|
|
|
|
module = __name__.split(".")[-1]
|
|
|
|
if module == "date":
|
|
|
|
return "date::<strftime format string, defaults to %x>"
|
|
|
|
if module == "time":
|
|
|
|
return "time::<strftime format string, defaults to %X>"
|
|
|
|
return "datetime::<strftime format string, defaults to '%x %X'>"
|
|
|
|
|
|
|
|
def notes():
|
|
|
|
return "none"
|
|
|
|
|
|
|
|
def description():
|
|
|
|
return "Displays the current time, using the optional format string as input for strftime."
|
|
|
|
|
2016-10-30 17:56:04 +01:00
|
|
|
class Module(bumblebee.module.Module):
|
2016-11-05 08:11:08 +01:00
|
|
|
def __init__(self, output, config):
|
|
|
|
super(Module, self).__init__(output, config)
|
2016-10-31 14:27:51 +01:00
|
|
|
|
2016-10-31 11:11:53 +01:00
|
|
|
module = self.__module__.split(".")[-1]
|
2016-10-31 14:39:52 +01:00
|
|
|
default = "%x %X"
|
|
|
|
if module == "date":
|
|
|
|
default = "%x"
|
|
|
|
if module == "time":
|
|
|
|
default = "%X"
|
2016-10-31 11:11:53 +01:00
|
|
|
|
2016-11-05 08:11:08 +01:00
|
|
|
param_name = "{}.format".format(module)
|
|
|
|
self._fmt = config.parameter(param_name, default)
|
2016-10-30 17:30:09 +01:00
|
|
|
|
2016-11-05 08:59:43 +01:00
|
|
|
def widgets(self):
|
|
|
|
return [
|
2016-11-05 12:14:33 +01:00
|
|
|
bumblebee.output.Widget(self,
|
2016-11-05 08:59:43 +01:00
|
|
|
datetime.datetime.now().strftime(self._fmt)
|
|
|
|
)
|
|
|
|
]
|
2016-10-30 17:30:09 +01:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|