Merge pull request #156 from nayaverdier/master
CPU icon and datetime locale
This commit is contained in:
commit
17204dda91
2 changed files with 14 additions and 5 deletions
|
@ -6,6 +6,9 @@ Parameters:
|
||||||
* datetime.format: strftime()-compatible formatting string
|
* datetime.format: strftime()-compatible formatting string
|
||||||
* date.format : alias for datetime.format
|
* date.format : alias for datetime.format
|
||||||
* time.format : alias for datetime.format
|
* time.format : alias for datetime.format
|
||||||
|
* datetime.locale: locale to use rather than the system default
|
||||||
|
* date.locale : alias for datetime.locale
|
||||||
|
* time.locale : alias for datetime.locale
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
@ -13,8 +16,6 @@ import datetime
|
||||||
import locale
|
import locale
|
||||||
import bumblebee.engine
|
import bumblebee.engine
|
||||||
|
|
||||||
locale.setlocale(locale.LC_TIME, locale.getdefaultlocale())
|
|
||||||
|
|
||||||
ALIASES = [ "date", "time" ]
|
ALIASES = [ "date", "time" ]
|
||||||
|
|
||||||
def default_format(module):
|
def default_format(module):
|
||||||
|
@ -28,9 +29,17 @@ def default_format(module):
|
||||||
class Module(bumblebee.engine.Module):
|
class Module(bumblebee.engine.Module):
|
||||||
def __init__(self, engine, config):
|
def __init__(self, engine, config):
|
||||||
super(Module, self).__init__(engine, config,
|
super(Module, self).__init__(engine, config,
|
||||||
bumblebee.output.Widget(full_text=self.get_time)
|
bumblebee.output.Widget(full_text=self.get_time))
|
||||||
)
|
|
||||||
self._fmt = self.parameter("format", default_format(self.name))
|
self._fmt = self.parameter("format", default_format(self.name))
|
||||||
|
lcl = self.parameter("locale")
|
||||||
|
|
||||||
|
# can't use the default in "parameter" because we split the
|
||||||
|
# string, while 'getdefaultlocale' already returns a tuple
|
||||||
|
if lcl is None:
|
||||||
|
self._lcl = locale.getdefaultlocale()
|
||||||
|
else:
|
||||||
|
self._lcl = lcl.split(".")
|
||||||
|
locale.setlocale(locale.LC_TIME, self._lcl)
|
||||||
|
|
||||||
def get_time(self, widget):
|
def get_time(self, widget):
|
||||||
return datetime.datetime.now().strftime(self._fmt)
|
return datetime.datetime.now().strftime(self._fmt)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"time": { "prefix": "" },
|
"time": { "prefix": "" },
|
||||||
"datetime": { "prefix": "" },
|
"datetime": { "prefix": "" },
|
||||||
"memory": { "prefix": "" },
|
"memory": { "prefix": "" },
|
||||||
"cpu": { "prefix": "" },
|
"cpu": { "prefix": "" },
|
||||||
"disk": { "prefix": "" },
|
"disk": { "prefix": "" },
|
||||||
"dnf": { "prefix": "" },
|
"dnf": { "prefix": "" },
|
||||||
"pacman": { "prefix": "" },
|
"pacman": { "prefix": "" },
|
||||||
|
|
Loading…
Reference in a new issue