Created
February 22, 2021 05:57
-
-
Save fabiolimace/bd0afff9d5db7b0c0e9be91251431447 to your computer and use it in GitHub Desktop.
Programa de medicao de capacidade da bateria para bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Local: /usr/local/bin/ | |
| # Bateria: programa de medicao de capacidade da bateria | |
| # Autor: Fabio Lima CE | |
| # Data: 25-12-2009 | |
| echo "" | |
| cat /proc/acpi/battery/BAT1/info \ | |
| | grep "last full capacity:" \ | |
| | cut -c26-29 \ | |
| > /tmp/bat-capacity | |
| BATCAP=$(cut -f1 -d" " /tmp/bat-capacity) | |
| echo " Ultimo carregamento: $BATCAP mAh" | |
| cat /proc/acpi/battery/BAT1/state \ | |
| | grep "remaining capacity:" \ | |
| | cut -c26-29 \ | |
| > /tmp/bat-remaining | |
| BATREM=$(cut -f1 -d" " /tmp/bat-remaining) | |
| echo " Capacidade atual: $BATREM mAh" | |
| echo " ($BATREM * 100) / $BATCAP " | bc \ | |
| > /tmp/bat-percent | |
| BATPER=$(cat /tmp/bat-percent) | |
| echo " Percentual remanecente: $BATPER%" | |
| # Nivel: [||||||.................] | |
| BARRS= | |
| DOTS= | |
| for i in $(seq -s " " $BATPER) | |
| do | |
| if [ $(echo "$i % 4" | bc) -eq 0 ] | |
| then | |
| BARRS=$(echo $BARRS\|) | |
| fi | |
| done | |
| for j in $(seq -s " " $(echo "100 - $BATPER" | bc)) | |
| do | |
| if [ $(echo "$j % 4" | bc) -eq 0 ] | |
| then | |
| DOTS=$(echo $DOTS.) | |
| fi | |
| done | |
| echo "" | |
| echo " Nivel: [$BARRS$DOTS]" | |
| echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment