-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_conf.py
executable file
·60 lines (47 loc) · 1.6 KB
/
copy_conf.py
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
54
55
56
57
58
59
60
#!/usr/bin/env python
import subprocess
import shlex
import os
import json
HOME = os.getenv("HOME")
CONF_DIR = f"{HOME}/.config/"
def walk_dir(dir: str, omit: list[str] | None = None):
walked = os.listdir(f"{CONF_DIR+dir}")
app_name = dir.lstrip("/")
if omit:
for i in omit:
if i in walked:
walked.remove(i)
for item in walked:
target_items[app_name].append(f"{app_name}/{item}")
# "repository_dir" : ["path/to/local_item_one", "path/to/local_item_two"]
target_items: dict[str, list[str]] = {
"alacritty": [
"alacritty/alacritty.toml",
"alacritty/themes/themes/tokyo-night.toml",
],
"eww": [],
"feh": [],
"gtk-3.0": ["gtk-3.0/settings.ini"],
"neofetch": ["neofetch/config.conf"],
"nvim": ["nvim/lua/", "nvim/init.lua"],
"picom": ["picom/picom.conf"],
"tmux": ["tmux/tmux.conf", "tmux/tokyonight.tmux"],
"xmonad": [],
"systemd/user": ["systemd/user/xinput-xset.service", "systemd/user/usage"],
}
# specify directories/files to avoid copying over
walk_dir("/eww", ["eww-git"])
walk_dir("/feh")
walk_dir("/xmonad", [".stack-work", "xmonad-contrib-git", "xmonad-git"])
pp_target_items = json.dumps(target_items, indent=2)
print(f"The following items with be copied to this repository:\n{pp_target_items}")
confirm = input("Confirm and continue? [Y]es/[n]o: ")
if confirm.strip().lower() in ["", "y", "yes"]:
for t, c in target_items.items():
for i in c:
cmd = shlex.split(f"cp -rt ./{t} {CONF_DIR}{i} ")
subprocess.call(cmd)
else:
print("Operation cancelled.")
exit(1)