From 5d4a749b7c51649bcd3953cd1686856408d08121 Mon Sep 17 00:00:00 2001 From: davidpkj Date: Sat, 3 Dec 2022 22:26:26 +0100 Subject: Merge in dotfiles --- scripts/.local/bin/personal/rica | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 scripts/.local/bin/personal/rica (limited to 'scripts/.local/bin/personal/rica') diff --git a/scripts/.local/bin/personal/rica b/scripts/.local/bin/personal/rica new file mode 100755 index 0000000..5004785 --- /dev/null +++ b/scripts/.local/bin/personal/rica @@ -0,0 +1,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() -- cgit v1.2.3