diff options
Diffstat (limited to 'cusmodules/colors.py')
-rwxr-xr-x | cusmodules/colors.py | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/cusmodules/colors.py b/cusmodules/colors.py new file mode 100755 index 0000000..295fbd4 --- /dev/null +++ b/cusmodules/colors.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +import os +import sys +import json +import wallpaper +from pathlib import Path +from random import randint +from subprocess import run + +def random(colors): + colorcount = len(colors) - 1 + ranint = randint(0, colorcount) + rancol = colors[ranint] + + return rancol + +def setColor(home, color_dir, choice, **kwargs): + os.system(f'wal --theme {color_dir}/{choice}') + + with open(f"{home}/.cache/wal/colors.json", 'r') as f: + data = json.load(f) + + top_color = data["colors"].get('color8') + + bottom_color = data["colors"].get('color6') + + wallpaper.gen_pylogo(top_color, bottom_color) + + try: + if kwargs["norestart"] == True: + return 0 + + except: + pass + + #run(['qtile', 'shell', '-c', 'restart()']) + #run(['kill', '-SIGUSR1', os.popen('pidof qtile').read().strip('\n')]) + run(['qtile', 'shell', '-c', 'reload_config()']) + run([f'{home}/.local/bin/pywalfox', 'update']) + + return 0 + +def main(argc, argv): + home = str(Path.home()) + color_dir = f'{home}/.config/qtile/colors' + + try: + if argv[0] == '-c': + choice = argv[1] + + else: + choice = os.popen(f'ls {color_dir} | dmenu -p "Color:"').read().strip("\n") + + except: + choice = os.popen(f'ls {color_dir} | dmenu -p "Color:"').read().strip("\n") + + + if "" == choice: + return 0 + + elif "random" in choice: + colors = os.popen(f'ls {color_dir}').read().strip('\n').split('\n') + choice = random(colors) + + else: + pass + + setColor(home, color_dir, choice) + + return 0 + +if __name__ == '__main__': + sys.argv.pop(0) + argc = int(len(sys.argv)) + + try: + argv = sys.argv + + except: + argv = [] + + main(argc, argv) + |