mirror of
https://github.com/marcogll/omarchy_setup.git
synced 2026-01-13 13:25:16 +00:00
feat(power): integrate tlp and add battery management functions
This commit introduces a complete battery management solution by integrating TLP into the setup scripts and providing convenient control functions in Zsh. Key changes: - Adds `eco-batt` and `full-batt` functions to `.zshrc` to allow the user to easily switch between battery-saving (80%) and full-charge (100%) modes. - Modifies `modules/apps.sh` to automatically install the `tlp` package. - Adds logic to `modules/apps.sh` to enable and start the `tlp.service` so that power management is active on boot. - Updates the `zsh-help` function to include documentation for the new battery management commands.
This commit is contained in:
29
.zshrc
29
.zshrc
@@ -234,6 +234,30 @@ killport(){
|
||||
# Inicia un servidor HTTP simple en el directorio actual.
|
||||
serve(){ python -m http.server "${1:-8000}"; }
|
||||
|
||||
# --- Gestión de Batería (TLP) -----------------------------------------------
|
||||
# Funciones para controlar los umbrales de carga de la batería en laptops
|
||||
# compatibles, como las Huawei. Requiere TLP instalado y configurado.
|
||||
|
||||
# Pone la batería en modo "Eco" para prolongar su vida útil.
|
||||
# Limita la carga al 80%.
|
||||
eco-batt() {
|
||||
if command -v tlp >/dev/null 2>&1; then
|
||||
sudo tlp setcharge 70 80 && echo "🔋 Modo Eco activado: la carga se detendrá al 80%."
|
||||
else
|
||||
echo "❌ TLP no está instalado. No se puede gestionar la batería."
|
||||
fi
|
||||
}
|
||||
|
||||
# Pone la batería en modo de carga completa.
|
||||
# Permite que la batería se cargue al 100%.
|
||||
full-batt() {
|
||||
if command -v tlp >/dev/null 2>&1; then
|
||||
sudo tlp setcharge 99 100 && echo "⚡ Modo de carga completa activado: la batería cargará al 100%."
|
||||
else
|
||||
echo "❌ TLP no está instalado. No se puede gestionar la batería."
|
||||
fi
|
||||
}
|
||||
|
||||
# Muestra una lista de todos los alias y funciones personalizadas.
|
||||
zsh_help() {
|
||||
# --- Colores ---
|
||||
@@ -324,6 +348,11 @@ zsh_help() {
|
||||
print_command "clima" "Muestra el clima de Saltillo."
|
||||
print_command "zsh-help" "Muestra esta ayuda."
|
||||
|
||||
# --- Gestión de Batería (TLP) ---
|
||||
print_section "Gestión de Batería (TLP)"
|
||||
print_command "eco-batt" "Activa el modo Eco (carga hasta 80%)."
|
||||
print_command "full-batt" "Activa la carga completa (hasta 100%)."
|
||||
|
||||
# --- Descargas (yt-dlp) ---
|
||||
print_section "Descargas (yt-dlp)"
|
||||
print_command "ytm <url|bús>" "Descarga audio de YouTube como MP3."
|
||||
|
||||
@@ -160,6 +160,7 @@ run_module_main() {
|
||||
git curl wget base-devel unzip htop fastfetch btop
|
||||
vim nano tmux xdg-utils xdg-user-dirs stow
|
||||
gnome-keyring libsecret seahorse openssh rsync usbutils
|
||||
tlp
|
||||
)
|
||||
# Paquetes para desarrollo de software.
|
||||
local PACMAN_DEV=(
|
||||
@@ -344,6 +345,13 @@ EOF
|
||||
log_success "TeamViewer daemon habilitado e iniciado"
|
||||
fi
|
||||
|
||||
if command_exists tlp; then
|
||||
log_info "Habilitando servicio TLP para gestión de energía..."
|
||||
sudo systemctl enable tlp.service 2>/dev/null || true
|
||||
sudo systemctl start tlp.service 2>/dev/null || true
|
||||
log_success "TLP habilitado e iniciado."
|
||||
fi
|
||||
|
||||
log_success "Aplicaciones instaladas correctamente"
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user