2023-09-28 10:52:20 +02:00
|
|
|
#!venv/bin/python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
2023-11-13 11:02:35 +01:00
|
|
|
prog="Dotfiles sync",
|
|
|
|
description="Saves and restores my dotfiles",
|
2023-09-28 10:52:20 +02:00
|
|
|
)
|
2023-11-13 11:02:35 +01:00
|
|
|
parser.add_argument("action", choices=["save", "restore"])
|
2023-09-28 10:52:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
synced_files = [
|
2023-11-13 11:02:35 +01:00
|
|
|
("editor/helix/", "~/.config/helix/"),
|
|
|
|
("de/i3/", "~/.config/i3/"),
|
|
|
|
("de/hypr/", "~/.config/hypr/"),
|
2023-12-12 09:51:42 +01:00
|
|
|
("shell/bash/.bash_profile", "~/.bash_profile"),
|
2023-11-13 11:02:35 +01:00
|
|
|
("shell/bash/.bashrc", "~/.bashrc"),
|
|
|
|
("shell/bash/.bash_aliases", "~/.bash_aliases"),
|
|
|
|
("shell/bash/.bash_env", "~/.bash_env"),
|
|
|
|
("shell/bash/.bash_exec", "~/.bash_exec"),
|
|
|
|
("shell/nu/.nu_aliases", "~/.nu_aliases"),
|
|
|
|
("term/rio/", "~/.config/rio/"),
|
|
|
|
("term/alacritty/", "~/.config/alacritty/"),
|
|
|
|
("bar/waybar/", "~/.config/waybar/"),
|
|
|
|
("bar/i3status-rust/", "~/.config/i3status-rust/"),
|
2024-01-03 15:09:10 +01:00
|
|
|
("bar/eww/", "~/.config/eww/"),
|
2023-11-13 11:02:35 +01:00
|
|
|
("home/xinitrc", "~/.xinitrc"),
|
|
|
|
("misc/picom/", "~/.config/picom/"),
|
|
|
|
("misc/runst/", "~/.config/runst/"),
|
|
|
|
("misc/mako/", "~/.config/mako/"),
|
2024-01-04 10:44:49 +01:00
|
|
|
("misc/swayosd/", "~/.config/swayosd"),
|
2023-11-13 11:02:35 +01:00
|
|
|
("misc/x11-toggle-gpu/", "~/.local/share/x11-toggle-gpu/"),
|
|
|
|
("bin/swaylock-hyprland", "~/.local/bin/swaylock-hyprland"),
|
|
|
|
("bin/Hyprland", "~/.local/bin/Hyprland"),
|
|
|
|
("bin/jaaj", "~/.local/bin/jaaj"),
|
|
|
|
("bin/xtoggle-touchpad", "~/.local/bin/xtoggle-touchpad"),
|
|
|
|
("bin/wtoggle-touchpad", "~/.local/bin/wtoggle-touchpad"),
|
|
|
|
("bin/togglescreen", "~/.local/bin/togglescreen"),
|
|
|
|
("bin/mc-key-fix", "~/.local/bin/mc-key-fix"),
|
|
|
|
("bin/x11-toggle-primary-gpu", "~/.local/bin/x11-toggle-primary-gpu"),
|
2023-11-21 13:34:32 +01:00
|
|
|
("bin/uwu-launcher", "~/.local/bin/uwu-launcher"),
|
2023-12-12 10:18:07 +01:00
|
|
|
# Submodules
|
|
|
|
("Ahurac-dotfiles/bin/ssh-fwd", "~/.local/bin/ssh-fwd"),
|
2023-09-28 10:52:20 +02:00
|
|
|
]
|
|
|
|
|
2023-11-13 11:02:35 +01:00
|
|
|
|
2023-09-28 10:52:20 +02:00
|
|
|
def save():
|
2023-11-13 11:02:35 +01:00
|
|
|
for p in synced_files:
|
2023-09-28 11:08:06 +02:00
|
|
|
folder = "/".join(p[0].split("/")[0:-1])
|
|
|
|
if not os.path.exists(folder):
|
|
|
|
os.mkdir(folder)
|
2023-09-28 10:52:20 +02:00
|
|
|
os.system(f"rsync -r {p[1]} {p[0]}")
|
2023-11-13 11:02:35 +01:00
|
|
|
|
|
|
|
|
2023-09-28 10:52:20 +02:00
|
|
|
def restore():
|
2023-11-13 11:02:35 +01:00
|
|
|
for p in synced_files:
|
2023-09-28 10:52:20 +02:00
|
|
|
os.system(f"rsync -r {p[0]} {p[1]}")
|
|
|
|
|
2023-11-13 11:02:35 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-09-28 10:52:20 +02:00
|
|
|
args = parser.parse_args()
|
2023-11-13 11:02:35 +01:00
|
|
|
if args.action == "save":
|
2023-09-28 10:52:20 +02:00
|
|
|
save()
|
2023-11-13 11:02:35 +01:00
|
|
|
elif args.action == "restore":
|
2023-09-28 10:52:20 +02:00
|
|
|
restore()
|