i3pystatus/i3pystatus/clock.py
enkore 612faaaa4e Adopted modules to new settings system
Btw. nothing has changed for the config files. You can pass into
__init__ a dict as before, or you can use keyword arguments.

Either way, a module defines the settings that can be specified
and those which are required. __init__ basically checks that all
required options are set and that no invalid options are used.
2013-02-23 00:12:45 +01:00

37 lines
946 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, locale, datetime
from i3pystatus import IntervalModule
class Clock(IntervalModule):
"""
This class shows a clock
"""
settings = ("format",)
format = None
def init(self):
lang = os.environ.get('LANG', None)
if lang:
locale.setlocale(locale.LC_ALL, lang)
if self.format is not None:
lang = locale.getlocale()[0]
if lang == 'en_US':
# MDY format - United States of America
self.format = "%a %b %-d %X"
else:
# DMY format - almost all other countries
self.format = "%a %-d %b %X"
def run(self):
full_text = datetime.datetime.now().strftime(self.format)
self.output = {
"full_text": full_text,
"name": "pyclock",
"urgent": False,
"color": "#ffffff"
}