Merge pull request #178 from richese/fixes

Fixes
This commit is contained in:
enkore 2015-03-16 16:03:20 +01:00
commit 0182372d92
2 changed files with 20 additions and 5 deletions

View File

@ -32,13 +32,24 @@ class Clock(IntervalModule):
on_downscroll = ["scroll_format", -1]
def init(self):
lang, enc = os.environ.get('LANG', None).split('.', 1)
if lang != locale.getlocale(locale.LC_TIME)[0]:
env_lang = os.environ.get('LC_TIME', None)
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
locale.setlocale(locale.LC_TIME, (lang, enc))
locale.setlocale(locale.LC_TIME, lang)
if self.format is None:
if lang == 'en_US':
if lang[0] == 'en_US':
# MDY format - United States of America
self.format = ["%a %b %-d %X"]
else:

View File

@ -80,6 +80,10 @@ class NowPlaying(IntervalModule):
def get_player(self):
if 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:
player = self.find_player()
return dbus.SessionBus().get_object(player, "/org/mpris/MediaPlayer2")