Make install.sh call gen-colours

This commit is contained in:
2026-03-10 11:07:31 +00:00
parent dc96e01021
commit 79886b4e55

View File

@@ -6,164 +6,173 @@ CONFIG_DIR="$HOME/.config"
BACKUP_DIR="" BACKUP_DIR=""
usage() { usage() {
echo "Usage: $(basename "$0") [OPTIONS] <target>..." echo "Usage: $(basename "$0") [OPTIONS] <target>..."
echo echo
echo "Targets:" echo "Targets:"
echo " hyprland Hyprland + waybar + wofi" echo " hyprland Hyprland + waybar + wofi"
echo " sway Sway + waybar + wofi" echo " sway Sway + waybar + wofi"
echo " i3 i3 + i3blocks + i3status" echo " i3 i3 + i3blocks + i3status"
echo " cursor Miku cursor theme" echo " cursor Miku cursor theme"
echo " shell Source bashrc/zshrc and add sh/ to PATH" echo " shell Source bashrc/zshrc and add sh/ to PATH"
echo " alacritty Add import to alacritty.toml" echo " alacritty Add import to alacritty.toml"
echo " tmux Source tmux.conf" echo " tmux Source tmux.conf"
echo " nvim Neovim (LazyVim) config" echo " nvim Neovim (LazyVim) config"
echo " vim Source vimrc" echo " vim Source vimrc"
echo " all Everything (uses hyprland as WM)" echo " all Everything (uses hyprland as WM)"
echo echo
echo "Options:" echo "Options:"
echo " -h, --help Show this help" echo " -h, --help Show this help"
} }
backup() { backup() {
local path="$1" local path="$1"
if [ -e "$path" ] || [ -L "$path" ]; then if [ -e "$path" ] || [ -L "$path" ]; then
if [ -z "$BACKUP_DIR" ]; then if [ -z "$BACKUP_DIR" ]; then
BACKUP_DIR="$SCRIPTS_DIR/backups/$(date +%Y%m%d_%H%M%S)" BACKUP_DIR="$SCRIPTS_DIR/backups/$(date +%Y%m%d_%H%M%S)"
mkdir -p "$BACKUP_DIR" mkdir -p "$BACKUP_DIR"
echo "Backing up existing configs to $BACKUP_DIR" echo "Backing up existing configs to $BACKUP_DIR"
fi
local name
name=$(basename "$path")
cp -a "$path" "$BACKUP_DIR/$name"
echo " Backed up $path"
fi fi
local name
name=$(basename "$path")
cp -a "$path" "$BACKUP_DIR/$name"
echo " Backed up $path"
fi
} }
link() { link() {
local src="$1" dest="$2" local src="$1" dest="$2"
backup "$dest" backup "$dest"
rm -rf "$dest" rm -rf "$dest"
ln -sf "$src" "$dest" ln -sf "$src" "$dest"
echo " Linked $dest -> $src" echo " Linked $dest -> $src"
} }
append_if_missing() { append_if_missing() {
local file="$1" line="$2" local file="$1" line="$2"
if [ ! -f "$file" ]; then if [ ! -f "$file" ]; then
echo "$line" > "$file" echo "$line" >"$file"
echo " Created $file with: $line" echo " Created $file with: $line"
elif ! grep -qF "$line" "$file"; then elif ! grep -qF "$line" "$file"; then
echo "" >> "$file" echo "" >>"$file"
echo "$line" >> "$file" echo "$line" >>"$file"
echo " Appended to $file: $line" echo " Appended to $file: $line"
else else
echo " Already in $file: $line" echo " Already in $file: $line"
fi fi
} }
install_hyprland() { install_hyprland() {
echo "Installing Hyprland configs..." echo "Installing Hyprland configs..."
"$SCRIPTS_DIR/hypr/build.sh" "$SCRIPTS_DIR/hypr/build.sh"
"$SCRIPTS_DIR/waybar/build.sh" "$SCRIPTS_DIR/waybar/build.sh"
"$SCRIPTS_DIR/wofi/build.sh" "$SCRIPTS_DIR/wofi/build.sh"
mkdir -p "$CONFIG_DIR" mkdir -p "$CONFIG_DIR"
link "$SCRIPTS_DIR/hypr" "$CONFIG_DIR/hypr" link "$SCRIPTS_DIR/hypr" "$CONFIG_DIR/hypr"
link "$SCRIPTS_DIR/waybar" "$CONFIG_DIR/waybar" link "$SCRIPTS_DIR/waybar" "$CONFIG_DIR/waybar"
link "$SCRIPTS_DIR/wofi" "$CONFIG_DIR/wofi" link "$SCRIPTS_DIR/wofi" "$CONFIG_DIR/wofi"
} }
install_sway() { install_sway() {
echo "Installing Sway configs..." echo "Installing Sway configs..."
"$SCRIPTS_DIR/sway/build.sh" "$SCRIPTS_DIR/sway/build.sh"
"$SCRIPTS_DIR/waybar/build.sh" "$SCRIPTS_DIR/waybar/build.sh"
"$SCRIPTS_DIR/wofi/build.sh" "$SCRIPTS_DIR/wofi/build.sh"
mkdir -p "$CONFIG_DIR" mkdir -p "$CONFIG_DIR"
link "$SCRIPTS_DIR/sway" "$CONFIG_DIR/sway" link "$SCRIPTS_DIR/sway" "$CONFIG_DIR/sway"
link "$SCRIPTS_DIR/waybar" "$CONFIG_DIR/waybar" link "$SCRIPTS_DIR/waybar" "$CONFIG_DIR/waybar"
link "$SCRIPTS_DIR/wofi" "$CONFIG_DIR/wofi" link "$SCRIPTS_DIR/wofi" "$CONFIG_DIR/wofi"
} }
install_i3() { install_i3() {
echo "Installing i3 configs..." echo "Installing i3 configs..."
"$SCRIPTS_DIR/i3/build.sh" "$SCRIPTS_DIR/i3/build.sh"
mkdir -p "$CONFIG_DIR" mkdir -p "$CONFIG_DIR"
link "$SCRIPTS_DIR/i3" "$CONFIG_DIR/i3" link "$SCRIPTS_DIR/i3" "$CONFIG_DIR/i3"
link "$SCRIPTS_DIR/i3blocks" "$CONFIG_DIR/i3blocks" link "$SCRIPTS_DIR/i3blocks" "$CONFIG_DIR/i3blocks"
link "$SCRIPTS_DIR/i3status" "$CONFIG_DIR/i3status" link "$SCRIPTS_DIR/i3status" "$CONFIG_DIR/i3status"
} }
install_cursor() { install_cursor() {
echo "Installing cursor theme..." echo "Installing cursor theme..."
mkdir -p "$HOME/.local/share/icons" mkdir -p "$HOME/.local/share/icons"
link "$SCRIPTS_DIR/hatsune-miku-windows-linux-cursors/miku-cursor-linux" "$HOME/.local/share/icons/Miku Cursor" link "$SCRIPTS_DIR/hatsune-miku-windows-linux-cursors/miku-cursor-linux" "$HOME/.local/share/icons/Miku Cursor"
} }
install_shell() { install_shell() {
echo "Installing shell configs..." echo "Installing shell configs..."
if [ -f "$HOME/.zshrc" ] || [ "$SHELL" = *zsh* ]; then if [ -f "$HOME/.zshrc" ] || [ "$SHELL" = *zsh* ]; then
append_if_missing "$HOME/.zshrc" "source ~/scripts/zshrc" append_if_missing "$HOME/.zshrc" "source ~/scripts/zshrc"
append_if_missing "$HOME/.zshrc" 'export PATH="$HOME/scripts/sh:$PATH"' append_if_missing "$HOME/.zshrc" 'export PATH="$HOME/scripts/sh:$PATH"'
fi fi
if [ -f "$HOME/.bashrc" ] || [ "$SHELL" = *bash* ]; then if [ -f "$HOME/.bashrc" ] || [ "$SHELL" = *bash* ]; then
append_if_missing "$HOME/.bashrc" "source ~/scripts/bashrc" append_if_missing "$HOME/.bashrc" "source ~/scripts/bashrc"
append_if_missing "$HOME/.bashrc" 'export PATH="$HOME/scripts/sh:$PATH"' append_if_missing "$HOME/.bashrc" 'export PATH="$HOME/scripts/sh:$PATH"'
fi fi
} }
install_alacritty() { install_alacritty() {
echo "Installing Alacritty config..." echo "Installing Alacritty config..."
local conf="$CONFIG_DIR/alacritty/alacritty.toml" local conf="$CONFIG_DIR/alacritty/alacritty.toml"
mkdir -p "$CONFIG_DIR/alacritty" mkdir -p "$CONFIG_DIR/alacritty"
append_if_missing "$conf" 'import = ["~/scripts/alacritty.toml"]' append_if_missing "$conf" 'import = ["~/scripts/alacritty.toml"]'
} }
install_tmux() { install_tmux() {
echo "Installing tmux config..." echo "Installing tmux config..."
append_if_missing "$HOME/.tmux.conf" "source ~/scripts/tmux.conf" append_if_missing "$HOME/.tmux.conf" "source ~/scripts/tmux.conf"
} }
install_nvim() { install_nvim() {
echo "Installing Neovim config..." echo "Installing Neovim config..."
mkdir -p "$CONFIG_DIR" mkdir -p "$CONFIG_DIR"
link "$SCRIPTS_DIR/nvim" "$CONFIG_DIR/nvim" link "$SCRIPTS_DIR/nvim" "$CONFIG_DIR/nvim"
} }
install_vim() { install_vim() {
echo "Installing vim config..." echo "Installing vim config..."
append_if_missing "$HOME/.vimrc" "source ~/scripts/vimrc" append_if_missing "$HOME/.vimrc" "source ~/scripts/vimrc"
} }
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
usage usage
exit 1 exit 1
fi fi
targets=() targets=()
for arg in "$@"; do for arg in "$@"; do
case "$arg" in case "$arg" in
-h|--help) usage; exit 0 ;; -h | --help)
all) targets+=(hyprland cursor shell alacritty tmux nvim vim) ;; usage
*) targets+=("$arg") ;; exit 0
esac ;;
all) targets+=(hyprland cursor shell alacritty tmux nvim vim) ;;
*) targets+=("$arg") ;;
esac
done done
"$SCRIPTS_DIR/sh/gen-colors"
for target in "${targets[@]}"; do for target in "${targets[@]}"; do
case "$target" in case "$target" in
hyprland) install_hyprland ;; hyprland) install_hyprland ;;
sway) install_sway ;; sway) install_sway ;;
i3) install_i3 ;; i3) install_i3 ;;
cursor) install_cursor ;; cursor) install_cursor ;;
shell) install_shell ;; shell) install_shell ;;
alacritty) install_alacritty ;; alacritty) install_alacritty ;;
tmux) install_tmux ;; tmux) install_tmux ;;
nvim) install_nvim ;; nvim) install_nvim ;;
vim) install_vim ;; vim) install_vim ;;
*) echo "Unknown target: $target"; usage; exit 1 ;; *)
esac echo "Unknown target: $target"
usage
exit 1
;;
esac
done done
if [ -n "$BACKUP_DIR" ]; then if [ -n "$BACKUP_DIR" ]; then
echo echo
echo "Backups saved to: $BACKUP_DIR" echo "Backups saved to: $BACKUP_DIR"
fi fi
echo "Done!" echo "Done!"