#!/bin/sh trap "exit 1" EXIT INT test "$(id -u)" != 0 && sudo=sudo die () { echo "$@" 1>&2 } if ! stow --version > /dev/null 2>&1 then die "stow not installed or not found." die "install stow? (arch)" die -n ">" test "y" = "$(head -n 1)" && $sudo pacman -Sy stow || exit 1 fi if [ -n "${MACH:=$1}" ] then die "I: stowing for $MACH" else die "E: MACH not set" die "Enter valid value for 'MACH'" die "d(esktop) | s(erver) | l(aptop)" die -n ">" read MACH fi mkdir -p "$HOME/bin" mkdir -p "$HOME/.config" ln -sf "$(realpath "$0")" $HOME/bin/ cd "$(dirname "$(realpath "$0")")" || exit 1 case "$MACH" in "desktop" | "d" | "laptop" | "l") stow -d bin/ -t "$HOME/bin" -R common guiscripts menuscripts extra stow -d config/ -t "$HOME/.config" -R essentials common extra X theme xdg hyprland stow -d config/ -t "$HOME/" -R home ;; "server" | "s") stow -d bin/ -t "$HOME/bin" -R common serverscripts menuscripts stow -d config/ -t "$HOME/.config" -R essentials common stow -d config/ -t "$HOME/" -R home ;; *) die "E: invalid value for 'MACH'" break esac