def add_fish_func(name: str, file: str, copy=False): print_line(f"Adding {name} to Fish functions") if copy: copyfile(file, FISH_FUNCS_DIR.joinpath(name + ".fish")) else: link_file(file, FISH_FUNCS_DIR.joinpath(name + ".fish"))
def add_fish_hook(hook: Hook, name: str, file: str, copy=False): print_line(f"Adding {name} to Fish {hook.value} hooks") if copy: copyfile(file, FISH_HOOKS_DIR.joinpath(hook.value, name + ".fish")) else: link_file(file, FISH_HOOKS_DIR.joinpath(hook.value, name + ".fish"))
def install_plugins(self): for plugin in self.settings["zsh"]["plugins"]: install_zsh_plugin(plugin["name"], plugin["remote"]) link_file( script_dir.joinpath("docker-host.sh"), zsh_plugin_dir.joinpath("docker-host", "docker-host.plugin.zsh"), )
def setup_project_list(self): project_list = home_dir.joinpath(".project.list") if not file_exists(project_list): with open(project_list, "w") as f: f.write("") link_file(project_list, home_dir.joinpath(".warprc")) home_dir.joinpath("code").mkdir(parents=True, exist_ok=True)
def run(self): print_header("Setting up Minicom") for file in ["dfl", "fast"]: link_file( Path(__file__).parent.joinpath(f".minirc.{file}"), Path.home().joinpath(f".minirc.{file}"), ) install_pkg("minicom") if platform.is_linux: run_command("sudo usermod -a -G dialout $(whoami)", shell=True)
def run(self): if platform.is_mac: return print_header("Setting up Firefox profile") profiles = ConfigParser() profiles.read(MOZILLA_DIR.joinpath("profiles.ini")) default_profile = "" for k, v in profiles.items(): if v.get("Default", fallback=0) == "1": default_profile = v break profile_dir = MOZILLA_DIR.joinpath(default_profile.get("Path")) link_file(SCRIPT_DIR.joinpath("user.js"), profile_dir.joinpath("user.js"))
def run(self): print_header("Setting up Generic Configs") link_file(SCRIPT_DIR.joinpath("scripts"), HOME_DIR.joinpath(".scripts")) with os.scandir(SCRIPT_DIR.joinpath("config")) as configs: config_dir = HOME_DIR.joinpath(".config") for item in configs: if item.is_dir(): link_file(item.path, config_dir.joinpath(item.name)) if not platform.is_mac: run_command("systemctl --user daemon-reload") run_command("systemctl --user enable newsboat.timer") run_command("systemctl --user enable random_wallpaper.timer") if platform.is_arch: run_command("systemctl --user enable pacupdate.timer") self.exec_installer("configs/home", "home")
def run(self): if not platform.is_arch: return print_header("Setting up Pacman") link_file(SCRIPT_DIR.joinpath("pacman.conf"), Path("/etc/pacman.conf"), sudo=True) install_pkg("reflector", "arch-audit", "kernel-modules-hook") # Enable kernel module cleanup job run_command("sudo systemctl daemon-reload") run_command("sudo systemctl enable linux-modules-cleanup") # Hooks are symlinked individually to allow local hooks that are # not managed by this installer. with os.scandir(SCRIPT_DIR.joinpath("hooks")) as hooks: hook_dir = "/etc/pacman.d/hooks/" for item in hooks: link_file(item.path, Path(hook_dir + item.name), sudo=True) link_file( SCRIPT_DIR.joinpath("reflector.conf"), Path("/etc/xdg/reflector/reflector.conf"), sudo=True, ) run_command("sudo systemctl enable reflector.timer") run_command("sudo systemctl start reflector.timer")
def link_fish_configs(self): link_file(script_dir.joinpath("config.fish"), FISH_CFG_DIR.joinpath("config.fish")) link_file(script_dir.joinpath("aliases.fish"), FISH_CFG_DIR.joinpath("aliases.fish")) link_file( script_dir.joinpath("functions.fish"), FISH_CFG_DIR.joinpath("functions.fish"), )
def run(self): print_header("Setting up GPG") add_zsh_hook(Hook.POST, "10-gpg", SCRIPT_DIR.joinpath("setuphook.zsh")) add_fish_hook(Hook.POST, "10-gpg", SCRIPT_DIR.joinpath("setuphook.fish")) if file_exists(INSTALLED_CANARY) and "force" not in self.args: print_line("GPG already setup") return # Use macOS binary location for consistancy if not file_exists("/usr/local/bin/gpg2"): link_file("/usr/bin/gpg2", "/usr/local/bin/gpg2", sudo=True) self.install_pkgs() os.makedirs(GNUPG_DIR, exist_ok=True) link_file(SCRIPT_DIR.joinpath("gpg.conf"), GNUPG_DIR.joinpath("gpg.conf")) if platform.is_mac: link_file( SCRIPT_DIR.joinpath("gpg-agent.conf"), GNUPG_DIR.joinpath("gpg-agent.conf"), ) else: remove(GNUPG_DIR.joinpath("gpg-agent.conf")) run_command_no_out(f"chmod -R og-rwx {str(GNUPG_DIR)}") gpg_key = settings["gpg"]["key"] print_line(f"GPG Key: {gpg_key}") # Import my public key and trust it ultimately if "nokey" not in self.args: run_command(f"gpg2 --recv-keys {gpg_key}") trust_key = f"{gpg_key}:6:" run_command(f"echo '{trust_key}' | gpg2 --import-ownertrust", shell=True) if platform.is_fedora and file_exists( "/etc/xdg/autostart/gnome-keyring-ssh.desktop"): run_command( "sudo mv -f /etc/xdg/autostart/gnome-keyring-ssh.desktop /etc/xdg/autostart/gnome-keyring-ssh.desktop.inactive" ) # Idempotency run_command('rm -f "$HOME/.gnupg/.dotfile-installed.*"', shell=True) run_command(f"touch {str(INSTALLED_CANARY)}")
def link_files(self): print_line("Linking VSCode Settings", color=Color.MAGENTA) os.makedirs(SETTINGS_PATH, exist_ok=True) link_file( SCRIPT_DIR.joinpath("settings.json"), SETTINGS_PATH.joinpath("settings.json"), ) link_file( SCRIPT_DIR.joinpath("keybindings.json"), SETTINGS_PATH.joinpath("keybindings.json"), ) if dir_exists(SETTINGS_PATH.joinpath("snippets")): os.rmdir(SETTINGS_PATH.joinpath("snippets")) link_file(SCRIPT_DIR.joinpath("snippets"), SETTINGS_PATH.joinpath("snippets"))
def link_config(path): link_file(SCRIPT_DIR.joinpath(path), HOME_DIR.joinpath(path))
def install_theme(self): link_file( script_dir.joinpath("lfk.zsh-theme"), zsh_theme_dir.joinpath("lfk.zsh-theme"), )
def link_zsh_configs(self): link_file(script_dir.joinpath(".zshrc"), home_dir.joinpath(".zshrc")) link_file(script_dir.joinpath(".zsh_aliases"), home_dir.joinpath(".zsh_aliases")) link_file(script_dir.joinpath(".zsh_functions"), home_dir.joinpath(".zsh_functions"))
def setup_autocomplete(self): link_file(script_dir.joinpath("completion"), home_dir.joinpath(".zsh", "completion"))
def link_config(self): link_file( Path(__file__).parent.joinpath(".vimrc"), Path.home().joinpath(".config", "nvim", "init.vim"), )