Files
.dotfiles/setup/arch/install.py
T
2026-04-22 18:16:04 -05:00

61 lines
1.6 KiB
Python

import subprocess
import config
from pathlib import Path
def sym_link_dir():
confirm_link = input("Do you want to link home directories to external storage? (Y/n): ")
if confirm_link.lower() in ("y", "yes", ""):
target_dir = input("Specify the full path to the external storage: ")
if Path(target_dir).is_dir():
for dir in config.DIRECTORIES:
DIR_ITEM = Path(f"{Path.home()}/{dir}")
if not DIR_ITEM.is_symlink():
if DIR_ITEM.is_dir():
DIR_ITEM.rmdir()
DIR_ITEM.symlink_to(f"{target_dir}/{dir}")
for dir in config.DIRECTORIES_TO_REMOVE:
DIR_ITEM = Path(f"{Path.home()}/{dir}")
if DIR_ITEM.is_dir() and not DIR_ITEM.is_symlink():
DIR_ITEM.rmdir()
def install_apps():
for app in config.APPS:
subprocess.run([
'sudo', 'pacman', '-S', f"{app}", '--noconfirm'
], check=True)
subprocess.run([
"fish", "-c", "fisher install jorgebucaran/nvm.fish"
], check=True)
subprocess.run([
"fish", "-c", "nvm install lts"
], check=True)
def stow_dot_files():
dotfiles_root = Path.home()/'.dotfiles'
for dotfile in config.DOTFILES:
subprocess.run([
'stow', '-d', str(dotfiles_root), dotfile, '--adopt'
], check=True)
subprocess.run(
['git', 'checkout', '--', *config.DOTFILES],
cwd=dotfiles_root,
check=True,
)
if __name__ == "__main__":
sym_link_dir()
install_apps()
stow_dot_files()