aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/personal/rica
blob: 5004785d871ef015cc54f7a0e8badea0a13110b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3

# A script to update the colors in specific config files for easy ricing.
# Depenencies: 
# By David Penkowoj, 2022-03-18

import os

# Get colors and loop over relevant configs
def replace_color_configs():
  with open("/home/me/.cache/wal/oldcolors") as old_color_file:
    old_colors = [ color.replace("\n", "") for color in old_color_file.readlines() ]

  with open("/home/me/.cache/wal/colors") as new_color_file:
    new_colors = [ color.replace("\n", "") for color in new_color_file.readlines() ]

  for config in relevant:
    config(old_colors, new_colors)

def find_and_replace_config(file_path, old_colors, new_colors):
  with open(file_path, "r") as file:
    data = file.read()

    for color in old_colors:
      if data.find(color) != -1:
        index = old_colors.index(color)
        data = data.replace(color, new_colors[index])

  with open(file_path, "w") as file:
    file.write(data)

# Change config for zathura
def change_zathura(old_colors, new_colors):
  file_path = "/home/me/.config/zathura/zathurarc"

  find_and_replace_config(file_path, old_colors, new_colors)

def change_qutebrowser(old_colors, new_colors):
  file_path = "/home/me/.config/qutebrowser/config.py"

  find_and_replace_config(file_path, old_colors, new_colors)

# change_nvim
# change_dunst,

relevant = [
  change_zathura,
  change_qutebrowser,
]

if __name__ == "__main__":
  os.system('xrdb merge "$HOME/.cache/wal/colors.Xresources"')
  replace_color_configs()