Last active
August 29, 2015 14:04
-
-
Save abaez/ece7404a4166937cbeeb to your computer and use it in GitHub Desktop.
Changes theme in termite terminal with base16-builder themes
This file contains hidden or 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
| #!/usr/bin/python | |
| themes = "./themes/" | |
| from os import listdir, chdir | |
| from os.path import isfile, join | |
| from random import randrange | |
| from time import strftime | |
| import sys | |
| def rec(s, m): | |
| if m in s: | |
| return s | |
| return rec(check(), m) | |
| # change the theme from dark to light based on time of day | |
| color = lambda : int(strftime("%H")) <= 16 and "light" or "dark" | |
| if __name__ == "__main__": | |
| """ | |
| The startup | |
| """ | |
| if len(sys.argv) < 2: | |
| sys.exit('Usage: %s [path to termite] [path to themes]' % sys.argv[0]) | |
| chdir(sys.argv[1]) | |
| themes = len(sys.argv) > 2 and sys.argv[2] + "/" or themes | |
| # produce file list | |
| fl = [ f for f in listdir(themes) if isfile(join(themes,f)) ] | |
| check = lambda : fl[randrange(len(fl))] | |
| with open("config", "w") as fw: | |
| with open("base.conf") as fr: | |
| for line in fr: | |
| fw.write(line) | |
| with open( themes + rec(check(), color())) as fr: | |
| for line in fr: | |
| fw.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment