From 3c96bff95501f7a2136aa4f350f845e337d0689a Mon Sep 17 00:00:00 2001 From: Marco Gallegos Date: Thu, 6 Nov 2025 15:00:46 -0600 Subject: [PATCH] Refactor omarchy-setup.sh for better error handling --- omarchy_zsh_setup/omarchy-setup.sh | 78 +++++++----------------------- 1 file changed, 18 insertions(+), 60 deletions(-) diff --git a/omarchy_zsh_setup/omarchy-setup.sh b/omarchy_zsh_setup/omarchy-setup.sh index 85f9d2e..3fa51db 100644 --- a/omarchy_zsh_setup/omarchy-setup.sh +++ b/omarchy_zsh_setup/omarchy-setup.sh @@ -11,15 +11,9 @@ # y descarga tus archivos personalizados de Omarchy. # =============================================================== -# --------------------------------------------------------------- -# 🧩 Seguridad: abortar si algo falla -# --------------------------------------------------------------- set -e trap 'echo "❌ Error en la lΓ­nea $LINENO. Abortando instalaciΓ³n."; exit 1' ERR -# --------------------------------------------------------------- -# 🎨 Banner de inicio -# --------------------------------------------------------------- cat << "EOF" ╔═════════════════════════════════════════════════════╗ β•‘ 🧠 Omarchy System Setup β•‘ @@ -28,9 +22,6 @@ cat << "EOF" EOF sleep 1 -# --------------------------------------------------------------- -# 🧰 ActualizaciΓ³n de sistema y herramientas base -# --------------------------------------------------------------- echo "πŸ”§ Actualizando sistema base..." sudo pacman -Syu --noconfirm @@ -43,9 +34,6 @@ sudo pacman -S --needed --noconfirm \ gnome-keyring openssh lsof ntp \ flatpak -# --------------------------------------------------------------- -# πŸ–₯️ Controladores Intel Iris Xe y codecs multimedia -# --------------------------------------------------------------- echo "🎞️ Instalando controladores y codecs para Intel Iris Xe..." sudo pacman -S --needed --noconfirm \ mesa libva-intel-driver intel-media-driver \ @@ -54,19 +42,14 @@ sudo pacman -S --needed --noconfirm \ gstreamer gst-libav gst-plugins-good gst-plugins-bad gst-plugins-ugly \ ffmpeg intel-compute-runtime clinfo -# opencl-clang (viene de AUR) if ! pacman -Q opencl-clang &>/dev/null; then echo "βš™οΈ Instalando opencl-clang desde AUR..." - yay -S --noconfirm opencl-clang + yay -S --noconfirm opencl-clang || echo "⚠️ No se pudo instalar opencl-clang (omitido)." fi -# --------------------------------------------------------------- -# 🎬 InstalaciΓ³n de VLC y codecs adicionales -# --------------------------------------------------------------- echo "🎧 Instalando VLC y codecs multimedia..." sudo pacman -S --needed --noconfirm vlc vlc-plugins-all -# Asociar archivos multimedia con VLC echo "πŸ—‚οΈ Configurando VLC como reproductor por defecto..." xdg-mime default vlc.desktop audio/mpeg xdg-mime default vlc.desktop audio/mp3 @@ -75,104 +58,79 @@ xdg-mime default vlc.desktop video/mp4 xdg-mime default vlc.desktop video/x-matroska xdg-mime default vlc.desktop video/x-msvideo -# --------------------------------------------------------------- -# 🧾 Impresoras Epson (L4150 + Epson Scan2) -# --------------------------------------------------------------- echo "πŸ–¨οΈ Instalando drivers Epson..." sudo pacman -S --needed --noconfirm cups sane simple-scan sudo systemctl enable --now cups.service -yay -S --needed --noconfirm epson-inkjet-printer-escpr2 epson-scanner-2 +yay -S --needed --noconfirm epson-inkjet-printer-escpr2 epson-scanner-2 || echo "⚠️ Epson scanner no disponible en AUR." # --------------------------------------------------------------- -# πŸ–±οΈ Logitech: ltunify y logiops +# βœ… Verificar e instalar yay si no existe +# --------------------------------------------------------------- +if ! command -v yay &>/dev/null; then + echo "πŸ“¦ Instalando yay (AUR helper)..." + cd /tmp + git clone https://aur.archlinux.org/yay-bin.git + cd yay-bin + makepkg -si --noconfirm + cd ~ +fi + +# --------------------------------------------------------------- +# πŸ–±οΈ Logitech: ltunify y logiops desde AUR # --------------------------------------------------------------- echo "πŸ–±οΈ Instalando soporte Logitech..." -sudo pacman -S --needed --noconfirm ltunify logiops +yay -S --noconfirm --needed ltunify logiops || echo "⚠️ No se pudieron instalar algunos paquetes Logitech (omitidos)." -# --------------------------------------------------------------- -# πŸ’» Aplicaciones grΓ‘ficas esenciales -# --------------------------------------------------------------- -echo "πŸͺŸ Instalando aplicaciones grΓ‘ficas..." -sudo pacman -S --needed --noconfirm \ - filezilla gedit code cursor telegram-desktop +echo "πŸ’» Instalando aplicaciones grΓ‘ficas..." +sudo pacman -S --needed --noconfirm filezilla gedit code cursor telegram-desktop -# --------------------------------------------------------------- -# πŸ’„ InstalaciΓ³n de Zsh + Oh My Zsh + plugins + Oh My Posh -# --------------------------------------------------------------- echo "πŸ’„ Instalando Zsh y entorno de shell..." sudo pacman -S --needed --noconfirm zsh - -# Cambiar shell por defecto a Zsh if [ "$SHELL" != "/bin/zsh" ]; then chsh -s /bin/zsh fi -# Instalar Oh My Zsh si no existe if [ ! -d "$HOME/.oh-my-zsh" ]; then echo "🌈 Instalando Oh My Zsh..." RUNZSH=no KEEP_ZSHRC=yes sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" fi -# Instalar plugins echo "πŸ”Œ Instalando plugins de Zsh..." ZSH_CUSTOM=${ZSH_CUSTOM:-~/.oh-my-zsh/custom} git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions 2>/dev/null || true git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting 2>/dev/null || true git clone https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/colorize $ZSH_CUSTOM/plugins/colorize 2>/dev/null || true -# Instalar Oh My Posh echo "✨ Instalando Oh My Posh..." curl -s https://ohmyposh.dev/install.sh | bash -s oh-my-posh font install meslo -# --------------------------------------------------------------- -# 🍺 InstalaciΓ³n de Homebrew -# --------------------------------------------------------------- echo "🍺 Instalando Homebrew..." if ! command -v brew &>/dev/null; then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi -# --------------------------------------------------------------- -# βš™οΈ ConfiguraciΓ³n de .bashrc para lanzar Zsh y Homebrew -# --------------------------------------------------------------- echo "βš™οΈ Ajustando ~/.bashrc..." cat << 'EOBASH' > ~/.bashrc -# Si no es interactivo, salir [[ $- != *i* ]] && return - -# Inicializar Homebrew eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - -# Lanzar Zsh automΓ‘ticamente si no estamos ya en Zsh if [ -t 1 ] && [ -z "$ZSH_VERSION" ]; then exec zsh fi EOBASH -# --------------------------------------------------------------- -# πŸ“₯ Descarga de configuraciones y scripts de Omarchy -# --------------------------------------------------------------- echo "πŸ“₯ Descargando configuraciones de Omarchy..." mkdir -p ~/Omarchy - curl -fsSL -o ~/.zshrc "https://raw.githubusercontent.com/marcogll/scripts_mg/refs/heads/main/omarchy_zsh_setup/.zshrc" curl -fsSL -o ~/Omarchy/omarchy-setup.sh "https://raw.githubusercontent.com/marcogll/scripts_mg/refs/heads/main/omarchy_zsh_setup/omarchy-setup.sh" curl -fsSL -o ~/Omarchy/davinci_resolve_intel.sh "https://raw.githubusercontent.com/marcogll/scripts_mg/refs/heads/main/omarchy_zsh_setup/davince_resolve_intel.sh" - chmod +x ~/Omarchy/*.sh -# --------------------------------------------------------------- -# πŸ” Activar servicios bΓ‘sicos -# --------------------------------------------------------------- echo "πŸ”‘ Habilitando servicios..." sudo systemctl enable --now docker.service sudo systemctl enable --now ntpd.service sudo systemctl enable --now gnome-keyring-daemon.service || true -# --------------------------------------------------------------- -# βœ… Mensaje final -# --------------------------------------------------------------- cat << "EOF" ╔═══════════════════════════════════════════════════════════╗ β•‘ βœ… Sistema preparado con Γ©xito β€” Omarchy Setup β•‘