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
|
#!/usr/bin/env python3
# A script to update the colors in specific config files for easy ricing.
# 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:
find_and_replace_config(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)
relevant = [
"/home/me/.config/dunst/dunstrc",
"/home/me/.config/zathura/zathurarc",
"/home/me/.config/flameshot/flameshot.ini",
"/home/me/.config/qutebrowser/utils.py",
]
if __name__ == "__main__":
os.system('xrdb -merge "$HOME/.cache/wal/colors.Xresources"')
os.system('xrdb -merge "$HOME/.Xresources"')
replace_color_configs()
os.system('killall dunst')
|