mirror of
https://github.com/marcogll/omarchy_setup.git
synced 2026-01-13 13:25:16 +00:00
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:
committed by
GitHub
parent
a2fbb1166b
commit
eabfe0cbaf
@@ -2,75 +2,123 @@
|
||||
# ===============================================================
|
||||
# mouse_cursor.sh - Instala y configura el tema de cursor Bibata
|
||||
# ===============================================================
|
||||
#
|
||||
# Este módulo automatiza la descarga, instalación y configuración
|
||||
# del tema de cursor "Bibata-Modern-Ice".
|
||||
#
|
||||
# Funciones principales:
|
||||
# - Descarga el tema de cursor desde su repositorio de GitHub.
|
||||
# - Lo instala en el directorio ~/.icons del usuario.
|
||||
# - Configura el cursor para Hyprland, modificando el fichero
|
||||
# `~/.config/hypr/envs.conf`.
|
||||
# - Configura el cursor para aplicaciones GTK a través de `gsettings`.
|
||||
#
|
||||
# Dependencias: curl, tar, gsettings (parte de glib2).
|
||||
#
|
||||
# ===============================================================
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/common.sh"
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# check_cursor_deps()
|
||||
# ---------------------------------------------------------------
|
||||
# Verifica que las dependencias necesarias para este módulo estén
|
||||
# instaladas.
|
||||
# ---------------------------------------------------------------
|
||||
check_cursor_deps() {
|
||||
local missing_deps=0
|
||||
for cmd in curl tar gsettings; do
|
||||
if ! command_exists "$cmd"; then
|
||||
log_error "El comando '$cmd' es necesario pero no está instalado."
|
||||
((missing_deps++))
|
||||
fi
|
||||
done
|
||||
return $missing_deps
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# install_mouse_cursor()
|
||||
# ---------------------------------------------------------------
|
||||
# Orquesta todo el proceso de instalación y configuración del cursor.
|
||||
# ---------------------------------------------------------------
|
||||
install_mouse_cursor() {
|
||||
log_step "Instalación del Tema de Cursor (Bibata-Modern-Ice)"
|
||||
|
||||
# --- Variables ---
|
||||
if ! check_cursor_deps; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# --- Variables de Configuración ---
|
||||
local CURSOR_THEME='Bibata-Modern-Ice'
|
||||
local CURSOR_SIZE=24
|
||||
local ENVS_FILE="$HOME/.config/hypr/envs.conf"
|
||||
local AUTOSTART_FILE="$HOME/.config/hypr/autostart.conf"
|
||||
local HYPR_CONFIG_DIR="$HOME/.config/hypr"
|
||||
local ENVS_FILE="${HYPR_CONFIG_DIR}/envs.conf"
|
||||
local DOWNLOAD_URL="https://github.com/ful1e5/Bibata_Cursor/releases/download/v2.0.7/Bibata-Modern-Ice.tar.xz"
|
||||
local ARCHIVE_NAME="Bibata-Modern-Ice.tar.xz"
|
||||
|
||||
# --- Paso 1 y 2: Descargar, Extraer e Instalar ---
|
||||
# --- 1. Descarga e Instalación ---
|
||||
log_info "Descargando e instalando el tema de cursor..."
|
||||
local TEMP_DIR
|
||||
TEMP_DIR=$(mktemp -d -p "/tmp" cursor_setup_XXXXXX)
|
||||
trap 'rm -rf "${TEMP_DIR}"' EXIT # Limpieza automática al salir
|
||||
|
||||
if curl -sL "$DOWNLOAD_URL" -o "${TEMP_DIR}/${ARCHIVE_NAME}"; then
|
||||
tar -xJf "${TEMP_DIR}/${ARCHIVE_NAME}" -C "${TEMP_DIR}"
|
||||
mkdir -p "$HOME/.icons"
|
||||
# Asegurar una instalación limpia eliminando la versión anterior si existe
|
||||
if [ -d "${TEMP_DIR}/${CURSOR_THEME}" ]; then
|
||||
rm -rf "$HOME/.icons/${CURSOR_THEME}" # Eliminar destino para evitar conflictos
|
||||
if mv "${TEMP_DIR}/${CURSOR_THEME}" "$HOME/.icons/"; then
|
||||
log_success "Tema de cursor instalado en ~/.icons/"
|
||||
else
|
||||
log_error "No se pudo mover el tema del cursor a ~/.icons/"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
log_error "El directorio del tema '${CURSOR_THEME}' no se encontró en el archivo."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
if ! curl -sL "$DOWNLOAD_URL" -o "${TEMP_DIR}/${ARCHIVE_NAME}"; then
|
||||
log_error "No se pudo descargar el tema de cursor desde $DOWNLOAD_URL"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# --- Paso 3: Configurar variables de entorno para Hyprland ---
|
||||
if [ -f "$ENVS_FILE" ]; then
|
||||
log_info "Configurando variables de entorno en $ENVS_FILE..."
|
||||
if ! grep -q "HYPRCURSOR_THEME,${CURSOR_THEME}" "$ENVS_FILE"; then
|
||||
echo -e "\n# Custom Cursor Theme" >> "$ENVS_FILE"
|
||||
echo "env = HYPRCURSOR_THEME,$CURSOR_THEME" >> "$ENVS_FILE"
|
||||
echo "env = HYPRCURSOR_SIZE,$CURSOR_SIZE" >> "$ENVS_FILE"
|
||||
echo "env = XCURSOR_THEME,$CURSOR_THEME" >> "$ENVS_FILE"
|
||||
echo "env = XCURSOR_SIZE,$CURSOR_SIZE" >> "$ENVS_FILE"
|
||||
log_success "Variables de cursor añadidas a Hyprland."
|
||||
else
|
||||
log_info "Las variables de cursor para Hyprland ya parecen estar configuradas."
|
||||
tar -xJf "${TEMP_DIR}/${ARCHIVE_NAME}" -C "${TEMP_DIR}"
|
||||
mkdir -p "$HOME/.icons"
|
||||
|
||||
# Asegura una instalación limpia eliminando la versión anterior si existe.
|
||||
if [[ -d "${TEMP_DIR}/${CURSOR_THEME}" ]]; then
|
||||
rm -rf "$HOME/.icons/${CURSOR_THEME}"
|
||||
if ! mv "${TEMP_DIR}/${CURSOR_THEME}" "$HOME/.icons/"; then
|
||||
log_error "No se pudo mover el tema del cursor a ~/.icons/"
|
||||
return 1
|
||||
fi
|
||||
log_success "Tema de cursor instalado en ~/.icons/"
|
||||
else
|
||||
log_error "El directorio del tema '${CURSOR_THEME}' no se encontró en el archivo descargado."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# --- Paso 4: Configurar GTK ---
|
||||
log_info "Configurando el cursor para aplicaciones GTK..."
|
||||
gsettings set org.gnome.desktop.interface cursor-theme "$CURSOR_THEME"
|
||||
gsettings set org.gnome.desktop.interface cursor-size "$CURSOR_SIZE"
|
||||
log_success "Configuración de GSettings aplicada."
|
||||
# --- 2. Configuración para Hyprland ---
|
||||
log_info "Configurando el cursor para Hyprland..."
|
||||
mkdir -p "$HYPR_CONFIG_DIR"
|
||||
touch "$ENVS_FILE"
|
||||
|
||||
log_success "¡Configuración del cursor completada!"
|
||||
log_warning "Por favor, cierra sesión y vuelve a iniciarla para aplicar los cambios."
|
||||
# Elimina configuraciones de cursor anteriores para evitar duplicados.
|
||||
sed -i '/^env = HYPRCURSOR_THEME/d' "$ENVS_FILE"
|
||||
sed -i '/^env = HYPRCURSOR_SIZE/d' "$ENVS_FILE"
|
||||
sed -i '/^env = XCURSOR_THEME/d' "$ENVS_FILE"
|
||||
sed -i '/^env = XCURSOR_SIZE/d' "$ENVS_FILE"
|
||||
|
||||
# Añade las nuevas variables de entorno.
|
||||
echo -e "\n# Configuración del Tema de Cursor (gestionado por Omarchy Setup)" >> "$ENVS_FILE"
|
||||
echo "env = HYPRCURSOR_THEME,$CURSOR_THEME" >> "$ENVS_FILE"
|
||||
echo "env = HYPRCURSOR_SIZE,$CURSOR_SIZE" >> "$ENVS_FILE"
|
||||
echo "env = XCURSOR_THEME,$CURSOR_THEME" >> "$ENVS_FILE"
|
||||
echo "env = XCURSOR_SIZE,$CURSOR_SIZE" >> "$ENVS_FILE"
|
||||
log_success "Variables de entorno para el cursor añadidas a $ENVS_FILE."
|
||||
|
||||
# --- 3. Configuración para Aplicaciones GTK ---
|
||||
log_info "Configurando el cursor para aplicaciones GTK..."
|
||||
if gsettings set org.gnome.desktop.interface cursor-theme "$CURSOR_THEME" && \
|
||||
gsettings set org.gnome.desktop.interface cursor-size "$CURSOR_SIZE"; then
|
||||
log_success "Configuración de GSettings para GTK aplicada correctamente."
|
||||
else
|
||||
log_error "No se pudo aplicar la configuración de GSettings para GTK."
|
||||
return 1
|
||||
fi
|
||||
|
||||
log_success "La configuración del cursor ha finalizado."
|
||||
log_warning "Para que todos los cambios surtan efecto, por favor, cierra sesión y vuelve a iniciarla."
|
||||
return 0
|
||||
}
|
||||
|
||||
# Ejecutar si se llama directamente
|
||||
# Ejecutar si se llama directamente al script.
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
install_mouse_cursor "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user