mirror of
https://github.com/flickowoa/dotfiles.git
synced 2026-04-06 00:32:09 +02:00
169 lines
5.6 KiB
Python
Executable File
169 lines
5.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import pywal
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
import numpy as np
|
|
import matplotlib as mpl
|
|
import time
|
|
|
|
THEME_DIR = os.environ.get("HYPRLAND_THEME")
|
|
print(THEME_DIR)
|
|
|
|
def colormix(c1,c2,mix=0):
|
|
#get np arrays c1 and c2 from hex
|
|
c1 = np.array(mpl.colors.to_rgb(c1))
|
|
c2 = np.array(mpl.colors.to_rgb(c2))
|
|
return mpl.colors.to_hex((1-mix)*c1 + mix*c2)
|
|
|
|
def alpha(c1,a):
|
|
c1 = np.array(mpl.colors.to_rgb(c1))
|
|
return mpl.colors.to_hex(c1 + (1-c1)*a)
|
|
|
|
def apply(pre=None,wallpaper=None):
|
|
if not pre:
|
|
colors = pywal.colors.get(wallpaper,backend="wal")
|
|
else:
|
|
colors = pre
|
|
print(wallpaper)
|
|
print("colors::::: ",colors)
|
|
|
|
# with open(os.path.expanduser("~/.config/Code/User/settings.json"),"r") as f:
|
|
# code_conf = json.load(f)
|
|
|
|
# if not code_conf.get("workbench.colorCustomizations"):
|
|
# code_conf["workbench.colorCustomizations"] = {}
|
|
|
|
# for key,value in code_conf["workbench.colorCustomizations"].items():
|
|
# value = value.strip()
|
|
# if value.startswith("#"):
|
|
# code_conf["workbench.colorCustomizations"][key] = colormix(value,colors["colors"][f"color5"],mix=0.1)
|
|
|
|
# with open(os.path.expanduser("~/.config/Code/User/settings.json"), "w") as f:
|
|
# json.dump(code_conf, f, indent=4)
|
|
|
|
cmd = f"swww img '{wallpaper}' --transition-type grow --transition-step 1 --transition-duration 1 --transition-pos 0.5,1.0"
|
|
subprocess.run(cmd,shell=True)
|
|
|
|
with open(os.path.expanduser("~/.config/hypr/themes/colors_base"),"r") as cr:
|
|
raw = cr.read()
|
|
new_colors = {}
|
|
|
|
for line in raw.split("\n"):
|
|
if line and not line.startswith("#"):
|
|
color,value = line.split(":")
|
|
if color.isnumeric():
|
|
new_colors[color.strip()] = colormix(value.strip(),colors["colors"]["color"+color.strip()],mix=0.75)
|
|
|
|
for color,value in colors["special"].items():
|
|
new_colors[color] = value
|
|
|
|
with open(os.path.expanduser("~/.config/hypr/themes/colors"),"w") as f:
|
|
for color,value in new_colors.items():
|
|
f.write(f"{color}: {value}\n")
|
|
|
|
with open(os.path.expanduser("~/.config/hypr/themes/uicolors"),"w") as f:
|
|
for color,value in colors["colors"].items():
|
|
f.write(f"{color[5:]}: {value}\n")
|
|
for color,value in colors["special"].items():
|
|
f.write(f"{color}: {value}\n")
|
|
|
|
subprocess.run("touch ~/.config/hypr/themes/uicolors",shell=True)
|
|
|
|
# active borders
|
|
gradient = ""
|
|
for color,value in colors["colors"].items():
|
|
gradient += f"rgba({value[1:]}ff) "
|
|
gradient += " 45deg"
|
|
cmd = f"hyprctl keyword general:col.active_border '{gradient}'"
|
|
print(cmd)
|
|
subprocess.run(cmd,shell=True)
|
|
|
|
# inactive borders
|
|
gradient = ""
|
|
for color,value in colors["colors"].items():
|
|
gradient += f"rgba({value[1:]}44) "
|
|
gradient += " 0deg"
|
|
cmd = f"hyprctl keyword general:col.inactive_border '{gradient}'"
|
|
print(cmd)
|
|
subprocess.run(cmd,shell=True)
|
|
|
|
cmd = f"hyprctl keyword decoration:col.shadow '0x33{colors['colors']['color5'][1:]}'"
|
|
print(cmd)
|
|
subprocess.run(cmd,shell=True)
|
|
|
|
cmd = f"hyprctl keyword decoration:col.shadow_inactive '0x22{colors['special']['background'][1:]}'"
|
|
print(cmd)
|
|
subprocess.run(cmd,shell=True)
|
|
|
|
#keyboard
|
|
cmd = f"asusctl led-mode static -c '{colors['colors']['color0'][1:]}'"
|
|
print(cmd)
|
|
subprocess.run(cmd,shell=True)
|
|
|
|
#cava
|
|
with open(os.path.expanduser("~/.config/cava/config"),"r") as f:
|
|
conf = f.read()
|
|
|
|
conf = conf.split("#--- cover2bg.py ---")[0]
|
|
|
|
conf += "\n#--- cover2bg.py ---\n" + f"""
|
|
[color]
|
|
background = '{colors["special"]["background"]}'
|
|
|
|
gradient = 1
|
|
|
|
gradient_color_1 = '{colors["colors"]["color0"]}'
|
|
gradient_color_2 = '{colors["colors"]["color1"]}'
|
|
gradient_color_3 = '{colors["colors"]["color2"]}'
|
|
gradient_color_4 = '{colors["colors"]["color3"]}'
|
|
gradient_color_5 = '{colors["colors"]["color4"]}'
|
|
gradient_color_6 = '{colors["colors"]["color5"]}'
|
|
gradient_color_7 = '{colors["colors"]["color6"]}'
|
|
gradient_color_8 = '{colors["colors"]["color7"]}'
|
|
"""
|
|
with open(os.path.expanduser("~/.config/cava/config"),"w") as f:
|
|
f.write(conf)
|
|
|
|
time.sleep(0.5)
|
|
subprocess.run("pkill -USR2 cava",shell=True)
|
|
subprocess.run("pkill -USR2 fish",shell=True)
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--index", help="wallpaper index")
|
|
parser.add_argument("--nosave", help="to save wallpaper to `currentwall` or not",action="store_true")
|
|
parser.add_argument("--reset", help="to set wallpaper in `currentwall`",action="store_true")
|
|
# parser.add_argument("cycle", help="cycle wall", required=False)
|
|
args = parser.parse_args()
|
|
|
|
if args.reset:
|
|
with open(os.path.join(THEME_DIR, "currentwall"),"r") as f:
|
|
index = f.read()
|
|
args.index = index
|
|
|
|
|
|
if args.index and args.index.isdigit():
|
|
index = int(args.index)
|
|
wallpaper = os.listdir(os.path.join(THEME_DIR, "wallpapers"))[index-1]
|
|
wallpaper = os.path.join(os.path.join(THEME_DIR, "wallpapers"),wallpaper)
|
|
else:
|
|
wallpaper = os.path.expanduser(args.index)
|
|
|
|
if not args.nosave:
|
|
with open(os.path.join(THEME_DIR, "currentwall"),"w") as f:
|
|
f.write(str(args.index))
|
|
|
|
try:
|
|
apply(wallpaper=wallpaper)
|
|
except:
|
|
wallpaper = os.listdir(os.path.join(THEME_DIR, "wallpapers"))[0]
|
|
wallpaper = os.path.join(os.path.join(THEME_DIR, "wallpapers"),wallpaper)
|
|
apply(wallpaper=wallpaper)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |