2023-09-28 10:52:20 +02:00
|
|
|
#!venv/bin/python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
prog='Dotfiles sync',
|
|
|
|
description='Saves and restores my dotfiles',
|
|
|
|
)
|
|
|
|
parser.add_argument('action', choices=['save', 'restore'])
|
|
|
|
|
|
|
|
|
|
|
|
synced_files = [
|
|
|
|
('editor/helix/', '~/.config/helix/'),
|
|
|
|
('de/i3/', '~/.config/i3/'),
|
2023-10-19 09:57:45 +02:00
|
|
|
('de/hypr/', '~/.config/hypr/'),
|
2023-09-28 10:52:20 +02:00
|
|
|
('shell/bash/.bashrc', '~/.bashrc'),
|
|
|
|
('shell/bash/.bash_aliases', '~/.bash_aliases'),
|
|
|
|
('shell/bash/.bash_env', '~/.bash_env'),
|
|
|
|
('shell/bash/.bash_exec', '~/.bash_exec'),
|
2023-09-28 11:02:00 +02:00
|
|
|
('shell/nu/.nu_aliases', '~/.nu_aliases'),
|
2023-10-10 16:59:49 +02:00
|
|
|
('term/rio/', '~/.config/rio/'),
|
|
|
|
('term/alacritty/', '~/.config/alacritty/'),
|
2023-10-19 09:57:45 +02:00
|
|
|
('bar/waybar/', '~/.config/waybar/'),
|
2023-10-29 13:56:07 +01:00
|
|
|
('bar/i3status-rust/', '~/.config/i3status-rust/'),
|
2023-10-29 12:40:36 +01:00
|
|
|
('home/xinitrc', '~/.xinitrc'),
|
2023-10-20 16:10:37 +02:00
|
|
|
('misc/picom/', '~/.config/picom/'),
|
2023-10-23 09:32:17 +02:00
|
|
|
('misc/runst/', '~/.config/runst/'),
|
2023-10-19 13:25:47 +02:00
|
|
|
|
|
|
|
('bin/swaylock-hyprland', '~/.local/bin/swaylock-hyprland'),
|
|
|
|
('bin/Hyprland', '~/.local/bin/Hyprland'),
|
|
|
|
('bin/jaaj', '~/.local/bin/jaaj'),
|
2023-10-29 12:40:36 +01:00
|
|
|
('bin/xtoggle-touchpad', '~/.local/bin/xtoggle-touchpad'),
|
|
|
|
('bin/wtoggle-touchpad', '~/.local/bin/wtoggle-touchpad'),
|
2023-10-19 13:25:47 +02:00
|
|
|
('bin/togglescreen', '~/.local/bin/togglescreen'),
|
|
|
|
('bin/mc-key-fix', '~/.local/bin/mc-key-fix'),
|
2023-09-28 10:52:20 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
def save():
|
|
|
|
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]}")
|
|
|
|
|
|
|
|
def restore():
|
|
|
|
for p in synced_files:
|
|
|
|
os.system(f"rsync -r {p[0]} {p[1]}")
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
args = parser.parse_args()
|
|
|
|
if args.action == 'save':
|
|
|
|
save()
|
|
|
|
elif args.action == 'restore':
|
|
|
|
restore()
|