Verificar status de carga da bateria do notebook
Publicado por Sandro Marcell (última atualização em 07/03/2014)
[ Hits: 14.787 ]
Homepage: http://sanmarcell.wordpress.com
Download 1381087011.battery_status (versão 2)
Download 1394198886.battery_status (versão 3)
De férias do trampo e sem ter muito o que fazer por enquanto :), criei esse simples Shell Script que mostra o status da carga da bateria do notebook, em forma de barra, porcentagem e tempo estimado restante para o fim total de carga da mesma. Não é lá essas coisas, mas funciona! Sugestões e melhorias serão bem-vindas. ;)
Versão 2 - Enviado por Sandro Marcell em 06/10/2013
Changelog: Remoção do POG! ;)
Download 1381087011.battery_status
Versão 3 - Enviado por Sandro Marcell em 07/03/2014
Changelog: Remoção da POG e algumas melhorias sutis... =)
Download 1394198886.battery_status
#!/bin/bash # # Copyright 2013 Sandro Marcell <smarcell@myopera.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. # PATH='/bin:/usr/bin:/usr/local/bin' bateria='BAT0' # Codigo UTF-8 para 'seta para cima' e 'seta para baixo' seta_cima='\u2191' seta_baixo='\u2193' exec 3< /sys/class/power_supply/${bateria}/energy_now; read -u3 capacidade_restante; exec 3<&- exec 3< /sys/class/power_supply/${bateria}/energy_full; read -u3 capacidade_total; exec 3<&- exec 3< /sys/class/power_supply/${bateria}/status; read -u3 estado_bateria; exec 3<&- exec 3< /sys/class/power_supply/${bateria}/power_now; read -u3 taxa_bateria; exec 3<&- ((carga = capacidade_restante * 100 / capacidade_total)) # Tempo restante estimado de carga ((taxa_bateria == 0)) && taxa_bateria=1 # POG!!! :P 100% de carga horas=$(bc <<< "(1.0 * $capacidade_restante) / (1.0 * $taxa_bateria)") minutos=$(bc <<< "(60.0 * $capacidade_restante) / $taxa_bateria - ($horas * 60)") case "$estado_bateria" in 'Full') status_bateria="{FONTE}33[1m=={FONTE}33[0m" info='Bateria recarregada';; 'Charging') status_bateria="{FONTE}33[1m${seta_cima}${seta_cima}{FONTE}33[0m" info='Bateria carregando...';; 'Discharging') status_bateria="{FONTE}33[1m${seta_baixo}${seta_baixo}{FONTE}33[0m" info="Tempo restante estimado = ${horas}h:${minutos}m" esac cor=32 # Codigo ANSI para cor verde if ((carga < 15)); then cor=31 # Vermelho elif ((carga <= 50)); then cor=33 # Amarelo fi # Mostra a barra while ((i++ < carga)); do (($i % 2 == 0)) && echo -ne "{FONTE}33[7;${cor}m {FONTE}33[0m" done echo -e " {FONTE}33[1;${cor}m${carga}%{FONTE}33[0m\n$status_bateria $info"
Conversor de binário pra decimal e vice-versa
Gravar uma imagem ISO em um CD-RW
InstallTXZ - converte e instala pacotes do Slackware no Debian
newchangelog - Script para gerar changelog.
Aprenda a Gerenciar Permissões de Arquivos no Linux
Como transformar um áudio em vídeo com efeito de forma de onda (wave form)
Como aprovar Pull Requests em seu repositório Github via linha de comando
Quebra de linha na data e hora no Linux Mint
Organizando seus PDF com o Zotero
tentando instalar em um notebook antigo o Linux LegacyOS_2023... [RESO... (8)
Problema com Conexão Outlook via Firewall (OpenSUSE) com Internet Fibr... (5)