This commit is contained in:
commit
07b0244dd9
@ -32,13 +32,24 @@ class Clock(IntervalModule):
|
|||||||
on_downscroll = ["scroll_format", -1]
|
on_downscroll = ["scroll_format", -1]
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
lang, enc = os.environ.get('LANG', None).split('.', 1)
|
env_lang = os.environ.get('LC_TIME', None)
|
||||||
if lang != locale.getlocale(locale.LC_TIME)[0]:
|
if env_lang is None:
|
||||||
|
env_lang = os.environ.get('LANG', None)
|
||||||
|
|
||||||
|
if env_lang is not None:
|
||||||
|
if env_lang.find('.') != -1:
|
||||||
|
lang = tuple(env_lang.split('.', 1))
|
||||||
|
else:
|
||||||
|
lang = (env_lang, None)
|
||||||
|
else:
|
||||||
|
lang = (None, None)
|
||||||
|
|
||||||
|
if lang != locale.getlocale(locale.LC_TIME):
|
||||||
# affects datetime.time.strftime() in whole program
|
# affects datetime.time.strftime() in whole program
|
||||||
locale.setlocale(locale.LC_TIME, (lang, enc))
|
locale.setlocale(locale.LC_TIME, lang)
|
||||||
|
|
||||||
if self.format is None:
|
if self.format is None:
|
||||||
if lang == 'en_US':
|
if lang[0] == 'en_US':
|
||||||
# MDY format - United States of America
|
# MDY format - United States of America
|
||||||
self.format = ["%a %b %-d %X"]
|
self.format = ["%a %b %-d %X"]
|
||||||
else:
|
else:
|
||||||
|
@ -29,6 +29,7 @@ class CpuUsage(IntervalModule):
|
|||||||
format = "{usage:02}%"
|
format = "{usage:02}%"
|
||||||
format_all = "{core}:{usage:02}%"
|
format_all = "{core}:{usage:02}%"
|
||||||
exclude_average = False
|
exclude_average = False
|
||||||
|
interval = 1
|
||||||
settings = (
|
settings = (
|
||||||
("format", "format string."),
|
("format", "format string."),
|
||||||
("format_all", ("format string used for {usage_all} per core. "
|
("format_all", ("format string used for {usage_all} per core. "
|
||||||
@ -40,7 +41,6 @@ class CpuUsage(IntervalModule):
|
|||||||
def init(self):
|
def init(self):
|
||||||
self.prev_total = defaultdict(int)
|
self.prev_total = defaultdict(int)
|
||||||
self.prev_busy = defaultdict(int)
|
self.prev_busy = defaultdict(int)
|
||||||
self.interval = 1
|
|
||||||
self.formatter = Formatter()
|
self.formatter = Formatter()
|
||||||
|
|
||||||
def get_cpu_timings(self):
|
def get_cpu_timings(self):
|
||||||
|
@ -337,7 +337,6 @@ class Network(IntervalModule, ColorRangeModule):
|
|||||||
format_values = dict(kbs="", network_graph="", bytes_sent="", bytes_recv="", packets_sent="", packets_recv="",
|
format_values = dict(kbs="", network_graph="", bytes_sent="", bytes_recv="", packets_sent="", packets_recv="",
|
||||||
interface="", v4="", v4mask="", v4cidr="", v6="", v6mask="", v6cidr="", mac="",
|
interface="", v4="", v4mask="", v4cidr="", v6="", v6mask="", v6cidr="", mac="",
|
||||||
essid="", freq="", quality="", quality_bar="")
|
essid="", freq="", quality="", quality_bar="")
|
||||||
color = None
|
|
||||||
if self.network_traffic:
|
if self.network_traffic:
|
||||||
network_usage = self.network_traffic.get_usage(self.interface)
|
network_usage = self.network_traffic.get_usage(self.interface)
|
||||||
format_values.update(network_usage)
|
format_values.update(network_usage)
|
||||||
@ -351,22 +350,22 @@ class Network(IntervalModule, ColorRangeModule):
|
|||||||
format_values['network_graph'] = self.get_network_graph(kbs)
|
format_values['network_graph'] = self.get_network_graph(kbs)
|
||||||
format_values['kbs'] = "{0:.1f}".format(round(kbs, 2)).rjust(6)
|
format_values['kbs'] = "{0:.1f}".format(round(kbs, 2)).rjust(6)
|
||||||
color = self.get_gradient(kbs, self.colors, self.upper_limit)
|
color = self.get_gradient(kbs, self.colors, self.upper_limit)
|
||||||
|
else:
|
||||||
|
color = None
|
||||||
|
|
||||||
|
if sysfs_interface_up(self.interface, self.unknown_up):
|
||||||
|
if not color:
|
||||||
|
color = self.color_up
|
||||||
|
format_str = self.format_up
|
||||||
|
else:
|
||||||
|
color = self.color_down
|
||||||
|
format_str = self.format_down
|
||||||
|
|
||||||
network_info = self.network_info.get_info(self.interface)
|
network_info = self.network_info.get_info(self.interface)
|
||||||
format_values.update(network_info)
|
format_values.update(network_info)
|
||||||
|
|
||||||
format_values['interface'] = self.interface
|
format_values['interface'] = self.interface
|
||||||
if sysfs_interface_up(self.interface, self.unknown_up):
|
|
||||||
if not self.dynamic_color:
|
|
||||||
color = self.color_up
|
|
||||||
|
|
||||||
self.output = {
|
self.output = {
|
||||||
"full_text": self.format_up.format(**format_values),
|
"full_text": format_str.format(**format_values),
|
||||||
'color': color,
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
color = self.color_down
|
|
||||||
self.output = {
|
|
||||||
"full_text": self.format_down.format(**format_values),
|
|
||||||
'color': color,
|
'color': color,
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,10 @@ class NowPlaying(IntervalModule):
|
|||||||
def get_player(self):
|
def get_player(self):
|
||||||
if self.player:
|
if self.player:
|
||||||
player = "org.mpris.MediaPlayer2." + self.player
|
player = "org.mpris.MediaPlayer2." + self.player
|
||||||
|
try:
|
||||||
|
return dbus.SessionBus().get_object(player, "/org/mpris/MediaPlayer2")
|
||||||
|
except dbus.exceptions.DBusException:
|
||||||
|
raise NoPlayerException()
|
||||||
else:
|
else:
|
||||||
player = self.find_player()
|
player = self.find_player()
|
||||||
return dbus.SessionBus().get_object(player, "/org/mpris/MediaPlayer2")
|
return dbus.SessionBus().get_object(player, "/org/mpris/MediaPlayer2")
|
||||||
|
Loading…
Reference in New Issue
Block a user