Refactor the installation script to improve reliability, user interaction, and review packages.
This commit is contained in:
1 parent
0a6ed82408
commit
c9c28be916
1 file changed
+120
-85
+120
-85
@@ -4,11 +4,12 @@ set -euo pipefail
|
||||
|
||||
DOTFILES_DIR="$HOME/dotfiles"
|
||||
|
||||
CYAN='[1;36m'
|
||||
BLUE='[1;34m'
|
||||
GREEN='[1;32m'
|
||||
YELLOW='[1;33m'
|
||||
RESET='[0m'
|
||||
CYAN='\033[1;36m'
|
||||
BLUE='\033[1;34m'
|
||||
GREEN='\033[1;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RESET='\033[0m'
|
||||
RED='\033[1;31m'
|
||||
|
||||
print_section() {
|
||||
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
@@ -19,11 +20,11 @@ print_section() {
|
||||
install_pacman() {
|
||||
for pkg in "$@"; do
|
||||
if ! pacman -Qq "$pkg" &>/dev/null; then
|
||||
echo -e "${BLUE}Установка: ${pkg}${RESET}"
|
||||
echo -e "${BLUE}Installing: ${pkg}${RESET}"
|
||||
sudo pacman -S --noconfirm --needed "$pkg"
|
||||
echo -e "${GREEN}Установлено: ${pkg}${RESET}"
|
||||
echo -e "${GREEN}Installed: ${pkg}${RESET}"
|
||||
else
|
||||
echo -e "${YELLOW}Пропущено (уже установлено): ${pkg}${RESET}"
|
||||
echo -e "${YELLOW}Skipped (already installed): ${pkg}${RESET}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -31,44 +32,83 @@ install_pacman() {
|
||||
install_yay() {
|
||||
for pkg in "$@"; do
|
||||
if ! yay -Qq "$pkg" &>/dev/null; then
|
||||
echo -e "${BLUE}Установка (AUR): ${pkg}${RESET}"
|
||||
echo -e "${BLUE}Installing (AUR): ${pkg}${RESET}"
|
||||
yay -S --noconfirm "$pkg"
|
||||
echo -e "${GREEN}Установлено (AUR): ${pkg}${RESET}"
|
||||
echo -e "${GREEN}Installed (AUR): ${pkg}${RESET}"
|
||||
else
|
||||
echo -e "${YELLOW}Пропущено (уже установлено): ${pkg}${RESET}"
|
||||
echo -e "${YELLOW}Skipped (already installed): ${pkg}${RESET}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
clone_repo() {
|
||||
print_section "Клонирование репозитория"
|
||||
git clone https://github.com/retrilzzy/dotfiles.git "$DOTFILES_DIR" || true
|
||||
print_section "Cloning or updating dotfiles repository"
|
||||
if [ -d "$DOTFILES_DIR" ]; then
|
||||
echo -e "${YELLOW}Dotfiles directory already exists. Attempting to pull latest changes.${RESET}"
|
||||
pushd "$DOTFILES_DIR" >/dev/null
|
||||
if git pull --rebase --autostash; then
|
||||
echo -e "${GREEN}Dotfiles updated successfully.${RESET}"
|
||||
else
|
||||
echo -e "${RED}Error: Failed to pull dotfiles. Please check your internet connection or repository access.${RESET}"
|
||||
popd >/dev/null
|
||||
exit 1
|
||||
fi
|
||||
popd >/dev/null
|
||||
else
|
||||
echo -e "${BLUE}Cloning dotfiles repository.${RESET}"
|
||||
if git clone --depth=10 https://github.com/retrilzzy/dotfiles.git "$DOTFILES_DIR"; then
|
||||
echo -e "${GREEN}Dotfiles cloned successfully.${RESET}"
|
||||
else
|
||||
echo -e "${RED}Error: Failed to clone dotfiles. Please check your internet connection or repository access.${RESET}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
setup_pacman() {
|
||||
print_section "Настройка Pacman"
|
||||
print_section "Configuring Pacman"
|
||||
|
||||
sudo cp /etc/pacman.conf /etc/pacman.conf.bak 2>/dev/null
|
||||
sudo cp "$DOTFILES_DIR/Configs/etc/pacman.conf" /etc/pacman.conf
|
||||
read -rp "$(echo -e "${YELLOW}Overwrite /etc/pacman.conf with default configuration? (Y/n): ${RESET}")" confirm
|
||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||
echo -e "${BLUE}Creating a backup of /etc/pacman.conf to /etc/pacman.conf.bak${RESET}"
|
||||
sudo cp /etc/pacman.conf /etc/pacman.conf.bak 2>/dev/null
|
||||
|
||||
sudo cp "$DOTFILES_DIR/Configs/etc/pacman.conf" /etc/pacman.conf
|
||||
echo -e "${GREEN}Pacman.conf overwritten.${RESET}"
|
||||
else
|
||||
echo -e "${YELLOW}Pacman.conf overwrite skipped.${RESET}"
|
||||
fi
|
||||
|
||||
print_section "Updating system"
|
||||
|
||||
sudo pacman -Syu --noconfirm
|
||||
|
||||
echo -e "${GREEN}Настройка Pacman завершена${RESET}"
|
||||
echo -e "${GREEN}Pacman configuration complete${RESET}"
|
||||
}
|
||||
|
||||
ensure_yay() {
|
||||
if ! command -v yay &>/dev/null; then
|
||||
print_section "Установка AUR помощника yay"
|
||||
print_section "Installing Yay"
|
||||
|
||||
sudo pacman -S --noconfirm --needed base-devel git
|
||||
git clone https://aur.archlinux.org/yay.git
|
||||
pushd yay
|
||||
sudo pacman -S --noconfirm --needed base-devel
|
||||
|
||||
tmp_dir=$(mktemp -d)
|
||||
git clone --depth=1 https://aur.archlinux.org/yay.git "$tmp_dir"
|
||||
|
||||
pushd "$tmp_dir" >/dev/null
|
||||
makepkg -si --noconfirm
|
||||
popd
|
||||
rm -rf yay
|
||||
echo -e "${GREEN}Yay установлен!${RESET}"
|
||||
popd >/dev/null
|
||||
|
||||
rm -rf "$tmp_dir"
|
||||
|
||||
if command -v yay &>/dev/null; then
|
||||
echo -e "${GREEN}Yay installed successfully!${RESET}"
|
||||
else
|
||||
echo -e "${RED}Error: yay installation failed.${RESET}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${YELLOW}Yay уже установлен${RESET}"
|
||||
echo -e "${YELLOW}Yay is already installed${RESET}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -77,13 +117,13 @@ setup_zsh_plugins() {
|
||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended || true
|
||||
fi
|
||||
sudo chsh -s /bin/zsh "$USER"
|
||||
git clone https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" || true
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" || true
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" || true
|
||||
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" || true
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" || true
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" || true
|
||||
}
|
||||
|
||||
backup_configs() {
|
||||
print_section "Резервное копирование существующих конфигураций"
|
||||
print_section "Backing up existing configurations"
|
||||
|
||||
local date_now
|
||||
date_now=$(date +%Y-%m-%d_%H-%M-%S)
|
||||
@@ -96,7 +136,7 @@ backup_configs() {
|
||||
local name
|
||||
name=$(basename "$dir")
|
||||
if [ -d "$HOME/.config/$name" ]; then
|
||||
echo -e "${BLUE} Копирование $HOME/.config/$name в $backup_dir/.config/${RESET}"
|
||||
echo -e "${BLUE} Copying $HOME/.config/$name to $backup_dir/.config/${RESET}"
|
||||
cp -a "$HOME/.config/$name" "$backup_dir/.config/"
|
||||
fi
|
||||
done
|
||||
@@ -104,7 +144,7 @@ backup_configs() {
|
||||
local home_files=(".zshrc" ".p10k.zsh" ".nanorc")
|
||||
for file in "${home_files[@]}"; do
|
||||
if [ -f "$HOME/$file" ]; then
|
||||
echo -e "${BLUE} Копирование $HOME/$file в $backup_dir/${RESET}"
|
||||
echo -e "${BLUE} Copying $HOME/$file to $backup_dir/${RESET}"
|
||||
cp -a "$HOME/$file" "$backup_dir/"
|
||||
fi
|
||||
done
|
||||
@@ -113,17 +153,17 @@ backup_configs() {
|
||||
local name
|
||||
name=$(basename "$dir")
|
||||
if [ -d "/etc/$name" ]; then
|
||||
echo -e "${BLUE} Копирование /etc/$name в $backup_dir/etc/${RESET}"
|
||||
echo -e "${BLUE} Copying /etc/$name to $backup_dir/etc/${RESET}"
|
||||
cp -a "/etc/$name" "$backup_dir/etc/"
|
||||
fi
|
||||
done
|
||||
shopt -u nullglob
|
||||
|
||||
echo -e "${GREEN}Бэкап сохранён в $backup_dir${RESET}"
|
||||
echo -e "${GREEN}Backup saved to $backup_dir${RESET}"
|
||||
}
|
||||
|
||||
apply_new_configs() {
|
||||
print_section "Применение новых конфигураций"
|
||||
print_section "Applying new configurations"
|
||||
|
||||
cp -a "$DOTFILES_DIR/Configs/.config/." "$HOME/.config/"
|
||||
|
||||
@@ -135,49 +175,67 @@ apply_new_configs() {
|
||||
|
||||
sudo cp -a "$DOTFILES_DIR/Configs/.local/." "$HOME/.local/"
|
||||
|
||||
echo -e "${GREEN}Новые конфигурации применены.${RESET}"
|
||||
echo -e "${GREEN}New configurations applied.${RESET}"
|
||||
}
|
||||
|
||||
setup_theme() {
|
||||
print_section "Применение темы"
|
||||
print_section "Applying theme"
|
||||
|
||||
gsettings set org.gnome.desktop.interface gtk-theme 'adw-gtk3-dark' && gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
|
||||
|
||||
nwg-look -a || echo -e "${YELLOW}Не удалось применить тему через nwg-look.${RESET}"
|
||||
nwg-look -a || echo -e "${YELLOW}Failed to apply theme via nwg-look.${RESET}"
|
||||
|
||||
echo -e "${GREEN}Темы применены.${RESET}"
|
||||
echo -e "${GREEN}Themes applied.${RESET}"
|
||||
}
|
||||
|
||||
setup_wallpapers() {
|
||||
local wallpaper_dest="$HOME/Pictures/Wallpapers"
|
||||
mkdir -p "$wallpaper_dest"
|
||||
cp -r "$DOTFILES_DIR/Assets/wallpapers/"* "$wallpaper_dest/"
|
||||
echo -e "${GREEN}Обои скопированы в $wallpaper_dest${RESET}"
|
||||
echo -e "${GREEN}Wallpapers copied to $wallpaper_dest${RESET}"
|
||||
|
||||
mkdir "$HOME/.local/share/color-schemes"
|
||||
mkdir "$HOME/.local/share/color-schemes" || true
|
||||
|
||||
uwsm app -- swww-daemon >/dev/null 2>&1 &
|
||||
disown
|
||||
|
||||
"$DOTFILES_DIR/Configs/.config/bin/change-wall.sh" ~/Pictures/Wallpapers
|
||||
echo -e "${GREEN}Обои установлены.${RESET}"
|
||||
echo -e "${GREEN}Wallpapers set.${RESET}"
|
||||
}
|
||||
|
||||
reload_services() {
|
||||
run_services() {
|
||||
print_section "Running services"
|
||||
|
||||
if pgrep -x "waybar" >/dev/null; then
|
||||
killall waybar && sleep 1
|
||||
fi
|
||||
|
||||
uwsm app -- waybar -c "$HOME/.config/waybar/config.jsonc" -s "$HOME/.config/waybar/styles.css" >/dev/null 2>&1 &
|
||||
disown
|
||||
|
||||
echo -e "${GREEN}Waybar перезапущен.${RESET}"
|
||||
uwsm app -- swaync -c "$HOME/.config/swaync/config.json" >/dev/null 2>&1 &
|
||||
disown
|
||||
|
||||
uwsm app -- nm-applet >/dev/null 2>&1 &
|
||||
disown
|
||||
|
||||
uwsm app -- wl-paste --type text --watch cliphist -max-items 50 store >/dev/null 2>&1 &
|
||||
disown
|
||||
|
||||
echo -e "${GREEN}Services started.${RESET}"
|
||||
}
|
||||
|
||||
main() {
|
||||
if [ -z "${WAYLAND_DISPLAY:-}" ]; then
|
||||
echo -e "${YELLOW}Скрипт должен запускаться в активной Wayland-сессии (Hyprland).${RESET}"
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo -e "${RED}Error: This script should not be run as root or with sudo. Please run it as a regular user.${RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}Запуск установки. 3...${RESET}" && sleep 1
|
||||
if [ -z "${WAYLAND_DISPLAY:-}" ]; then
|
||||
echo -e "${YELLOW}The script must be run in an active Wayland session (Hyprland).${RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}Starting installation. 3...${RESET}" && sleep 1
|
||||
echo -e "${CYAN}2...${RESET}" && sleep 1
|
||||
echo -e "${CYAN}1...${RESET}" && sleep 1
|
||||
|
||||
@@ -190,56 +248,33 @@ main() {
|
||||
|
||||
ensure_yay
|
||||
|
||||
print_section "Сетевые инструменты"
|
||||
install_pacman networkmanager network-manager-applet
|
||||
print_section "System and interface"
|
||||
install_pacman hyprlock hypridle kitty nwg-look rofi swaync waybar wlogout swww
|
||||
install_yay hyprshot waypaper
|
||||
|
||||
print_section "Установка PipeWire"
|
||||
install_pacman pipewire pipewire-pulse pipewire-audio pipewire-alsa
|
||||
print_section "Utilities and tools"
|
||||
install_pacman brightnessctl cliphist fastfetch grim lsd playerctl trash-cli uwsm wl-clipboard wl-clip-persist
|
||||
install_yay emote flameshot gpu-screen-recorder nautilus network-manager-applet
|
||||
|
||||
print_section "Bluetooth"
|
||||
install_pacman bluez blueman
|
||||
print_section "Networking, audio and portals"
|
||||
install_pacman networkmanager bluez blueman pipewire pipewire-pulse pipewire-audio pipewire-alsa polkit-gnome xdg-utils xdg-desktop-portal xdg-desktop-portal-hyprland xdg-desktop-portal-gtk xdg-desktop-portal-wlr xdg-desktop-portal-gnome
|
||||
|
||||
print_section "Интеграция с окружением"
|
||||
install_pacman xdg-utils xdg-desktop-portal xdg-desktop-portal-hyprland xdg-desktop-portal-gtk xdg-desktop-portal-wlr xdg-desktop-portal-gnome polkit-gnome
|
||||
print_section "Appearance and themes"
|
||||
install_pacman adw-gtk-theme frameworkintegration inter-font noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra papirus-icon-theme ttf-jetbrains-mono-nerd
|
||||
install_yay matugen-bin qt5ct-kde qt6ct-kde darkly-bin rose-pine-cursor rose-pine-hyprcursor ttf-meslo-nerd-font-powerlevel10k
|
||||
|
||||
print_section "Управление устройствами"
|
||||
install_pacman brightnessctl playerctl
|
||||
|
||||
print_section "Шрифты"
|
||||
install_pacman noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra ttf-jetbrains-mono-nerd inter-font
|
||||
install_yay ttf-meslo-nerd-font-powerlevel10k
|
||||
|
||||
print_section "Темы и иконки"
|
||||
install_yay rose-pine-cursor rose-pine-hyprcursor
|
||||
install_pacman papirus-icon-theme
|
||||
|
||||
print_section "Интерфейс и утилиты"
|
||||
install_yay wlogout swaync emote
|
||||
install_pacman waybar uwsm rofi hypridle wl-clipboard cliphist wl-clip-persist kitty flameshot fastfetch lsd trash-cli nautilus
|
||||
|
||||
print_section "Обои и оформление"
|
||||
install_yay waypaper swww matugen-bin
|
||||
|
||||
print_section "Скриншоты и запись экрана"
|
||||
install_pacman grim hyprshot
|
||||
install_yay gpu-screen-recorder
|
||||
|
||||
print_section "Zsh и плагины"
|
||||
print_section "Zsh and Plugins"
|
||||
install_pacman zsh
|
||||
setup_zsh_plugins
|
||||
|
||||
print_section "GTK и Qt оформление"
|
||||
install_yay qt6ct-kde qt5ct-kde darkly-qt5-git darkly-qt6-git
|
||||
install_pacman nwg-look adw-gtk-theme
|
||||
|
||||
backup_configs
|
||||
apply_new_configs
|
||||
setup_theme
|
||||
setup_wallpapers
|
||||
reload_services
|
||||
run_services
|
||||
|
||||
echo -e "${GREEN}Установка завершена!${RESET}"
|
||||
echo -e "${CYAN}Перезагрузите систему для полного применения изменений.${RESET}"
|
||||
echo -e "${GREEN}Installation complete!${RESET}"
|
||||
echo -e "${CYAN}It is recommended to reboot the system for changes to fully apply.${RESET}"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in new issue
Block a user