Created
May 10, 2017 07:27
-
-
Save asl97/64b3417312b5b15bc614e95e683b4f96 to your computer and use it in GitHub Desktop.
Read orage globaltime config and output times, useful for conky or i3bar kind of stuff.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pytz | |
import datetime | |
import configparser | |
config = configparser.ConfigParser() | |
config.read(os.path.expanduser("~")+"/.config/globaltime/globaltimerc") | |
now = datetime.datetime.now(pytz.UTC) | |
o = [] | |
for s in config.sections()[1:]: # ignore first section which should be the default values | |
c = dict(config.items(s)) | |
c["datetime"] = now.astimezone(pytz.timezone(c["tz"])).strftime("%H:%M") | |
o.append("{name}: {datetime}".format_map(c)) | |
print(" | ".join(o)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Performance is too slow as a standalone, decided to embed it instead: https://github.com/asl97/asl97-i3bar-status-spacer
Edit: Embed it as in turn it into an script for i3bar to run.