Refactor: Improve and Document All Modules and Readme.md (#3)

* docs: update and improve Readme.md in Spanish

Restore the comprehensive Spanish version of the `Readme.md` and add a new section with instructions for installing the Meslo font, which is required for the `oh-my-posh` theme to render correctly.

The new section is located in the "Troubleshooting" area and provides the necessary command (`oh-my-posh font install meslo`) to ensure a correct setup.

The rest of the document has been reviewed to ensure it is complete and accurately reflects the script's functionality.

* refactor: improve and document all modules and Readme.md

This is a major refactoring and documentation effort that touches every module in the project.

- **Exhaustive In-Code Documentation:** Every module script in the `modules/` directory has been updated with detailed comments. This includes header descriptions, explanations for each function, and justifications for complex logic. This greatly improves the maintainability and readability of the code.

- **Code Robustness and Optimization:** Several modules have been refactored to be more robust and efficient. This includes:
  - Optimizing package installations by grouping them into a single `pacman` command.
  - Improving dependency checks.
  - Standardizing the use of helper functions from `common.sh`.
  - Making network operations more resilient.

- **Comprehensive `Readme.md` Update:** The main `Readme.md` has been rewritten to be a complete and professional guide to the project. It now includes:
  - A clear and detailed description of each module.
  - Information on what each module installs and how it works.
  - Instructions for installing the required Nerd Font for `oh-my-posh`.
  - An updated structure that is easier to navigate.

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Marco Gallegos <marco.gallegos@outlook.com>
This commit is contained in:
google-labs-jules[bot]
2025-11-18 23:18:20 -06:00
committed by GitHub
parent a2fbb1166b
commit eabfe0cbaf
13 changed files with 820 additions and 1089 deletions

View File

@@ -2,6 +2,19 @@
# ===============================================================
# printer.sh - Configuración de impresoras (CUPS)
# ===============================================================
#
# Este módulo instala y configura el sistema de impresión CUPS
# (Common Unix Printing System) en Arch Linux.
#
# Funciones principales:
# - Instala CUPS, filtros de impresión y drivers genéricos.
# - Instala Avahi para la detección automática de impresoras en red.
# - Instala drivers específicos para impresoras Epson desde AUR.
# - Habilita y arranca los servicios de CUPS y Avahi.
# - Añade al usuario al grupo `lp` para permitir la administración
# de impresoras.
#
# ===============================================================
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/common.sh"
@@ -11,65 +24,65 @@ install_printer() {
local target_user="${SUDO_USER:-$USER}"
log_info "Instalando CUPS y paquetes base..."
# --- 1. Instalación de Paquetes Base ---
log_info "Instalando CUPS y paquetes base de impresión..."
# Paquetes:
# - cups, cups-pdf, cups-filters: El núcleo de CUPS.
# - ghostscript, gsfonts: Para interpretar PostScript.
# - gutenprint, foomatic-*: Drivers de impresión genéricos.
# - system-config-printer: Herramienta gráfica de configuración.
# - avahi, nss-mdns: Para descubrir impresoras en la red.
local base_pkgs=(
cups cups-pdf cups-filters
ghostscript gsfonts
gutenprint
cups cups-pdf cups-filters ghostscript gsfonts gutenprint
foomatic-db-engine foomatic-db foomatic-db-ppds
foomatic-db-nonfree foomatic-db-nonfree-ppds
system-config-printer
avahi nss-mdns
system-config-printer avahi nss-mdns
)
local pkg_failed=false
for pkg in "${base_pkgs[@]}"; do
if ! check_and_install_pkg "$pkg"; then
pkg_failed=true
fi
done
if [[ "$pkg_failed" == true ]]; then
log_warning "Algunos paquetes base no pudieron instalarse. Revisa los mensajes anteriores."
if ! sudo pacman -S --noconfirm --needed "${base_pkgs[@]}"; then
log_warning "Algunos paquetes base de impresión no pudieron instalarse. El servicio podría no funcionar."
fi
log_info "Instalando drivers para Epson (ESC/P-R)..."
# --- 2. Instalación de Drivers de AUR ---
log_info "Instalando drivers para impresoras Epson (desde AUR)..."
# Drivers específicos para modelos de inyección de tinta de Epson.
local aur_drivers=("epson-inkjet-printer-escpr" "epson-inkjet-printer-escpr2" "epson-printer-utility")
if ! aur_install_packages "${aur_drivers[@]}"; then
log_warning "No se pudieron instalar todos los drivers de Epson de forma automática. Revisa 'epson-inkjet-printer-escpr2' y 'epson-printer-utility' manualmente."
log_warning "No se pudieron instalar todos los drivers de Epson desde AUR. Revisa los mensajes de error."
fi
log_info "Verificando servicios de impresión..."
# --- 3. Habilitación de Servicios ---
log_info "Habilitando y arrancando los servicios de impresión..."
local services=("cups.service" "avahi-daemon.service")
for svc in "${services[@]}"; do
if sudo systemctl is-enabled "$svc" &>/dev/null; then
log_info "${svc} ya está habilitado."
else
if ! sudo systemctl is-enabled "$svc" &>/dev/null; then
sudo systemctl enable "$svc"
log_success "${svc} habilitado."
log_success "Servicio ${svc} habilitado."
fi
if sudo systemctl is-active "$svc" &>/dev/null; then
log_info "${svc} ya está en ejecución."
else
if ! sudo systemctl is-active "$svc" &>/dev/null; then
sudo systemctl start "$svc"
log_success "${svc} iniciado."
log_success "Servicio ${svc} iniciado."
fi
done
# --- 4. Configuración de Permisos de Usuario ---
# El usuario debe pertenecer al grupo `lp` para administrar impresoras.
if ! id -nG "$target_user" | grep -qw lp; then
log_info "Agregando usuario ${target_user} al grupo lp..."
log_info "Agregando al usuario '${target_user}' al grupo 'lp' para administrar impresoras..."
sudo usermod -aG lp "$target_user"
log_warning "Para que este cambio de grupo tenga efecto, es necesario cerrar sesión y volver a iniciarla."
else
log_info "El usuario ${target_user} ya pertenece al grupo lp."
log_info "El usuario '${target_user}' ya pertenece al grupo 'lp'."
fi
log_success "Dependencias de impresión instaladas."
log_info "Añade tu impresora Epson L4150 desde http://localhost:631 o con 'system-config-printer'."
log_info "El módulo no configura impresoras automáticamente; solo deja listas las dependencias."
log_success "La configuración de CUPS ha finalizado."
log_info "Puedes añadir y gestionar tus impresoras desde la interfaz web de CUPS en http://localhost:631"
log_info "o utilizando la herramienta gráfica 'system-config-printer'."
return 0
}
# Ejecutar si se llama directamente
# Ejecutar si se llama directamente al script.
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
install_printer "$@"
fi