mirror of https://framagit.org/kyodev/kyopages.git
getInfo 2.59.4
This commit is contained in:
parent
ffe80951df
commit
b4f33a0f44
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=2.59.3
|
||||
version=2.59.4
|
||||
date="9/12/2017"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||
|
@ -675,7 +675,7 @@ fi_batt(){ # 9/12/2017
|
|||
local pluriel
|
||||
|
||||
[ "$fg_batt" ] || figet_batt
|
||||
[[ "$fg_batt" || "$fg_nb_batt" -gt 0 ]] || return 0 # pas de batterie
|
||||
[ "$fg_batt" ] || return 0 # pas de batterie
|
||||
[ "$fg_nb_batt" -gt 1 ] && pluriel="s" || unset pluriel
|
||||
###
|
||||
f_pr titre2 "batterie"$pluriel
|
||||
|
@ -2225,21 +2225,19 @@ fi_vrms(){ # 1/12/2017
|
|||
|
||||
# informations batterie(s), assigne $fg_nb_batt $fg_batt $fg_batt_serial
|
||||
figet_batt(){ #v2 9/12/2017
|
||||
local batt_detail batt_nb batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
|
||||
local batt_detail batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
|
||||
local batt_volt_min batt_volt_now batt_status batt_cycle alert_batt_alarm
|
||||
local batt_sante batt_restant tempo batRep ibat uevent
|
||||
fg_nb_batt=0
|
||||
if [ ! -d /sys/class/power_supply ]; then # anciennes interfaces ou inconnu
|
||||
[ -d /proc/acpi/battery ] && batt_detail="ancienne interface ACPI non gérée (obsolète)"
|
||||
[ -e /proc/apm ] && batt_detail="anciennes batteries APM non gérées (obolète)"
|
||||
[ "$batt_detail" ] || batt_detail="répertoire power_supply inaccessible"
|
||||
batt_nb="-1"
|
||||
[ -d /proc/acpi/battery ] && fg_batt="ancienne interface ACPI non gérée (obsolète)"
|
||||
[ -e /proc/apm ] && fg_batt="anciennes batteries APM non gérées (obolète)"
|
||||
[ "$fg_batt" ] || fg_batt="répertoire power_supply inaccessible"
|
||||
return 1
|
||||
fi
|
||||
[ "$(grep -c 'BAT' <<< $(ls /sys/class/power_supply/ 2>/dev/null))" -gt 0 ] || return 0
|
||||
batt_nb="$(grep -i 'Battery' /sys/class/power_supply/*/type | grep -c .)"
|
||||
if [ "$batt_nb" ]; then
|
||||
fg_nb_batt=0
|
||||
return
|
||||
fg_nb_batt="$(grep -i 'Battery' /sys/class/power_supply/*/type | grep -c .)"
|
||||
if [ "$fg_nb_batt" -eq 0 ]; then
|
||||
return 0
|
||||
fi
|
||||
batRep="/sys/class/power_supply"
|
||||
unset batt_detail
|
||||
|
@ -2318,9 +2316,12 @@ figet_batt(){ #v2 9/12/2017
|
|||
batt_detail+="batterie très mal chargée (moins de 50%): mauvais état? "$'\n' #[ln 5]
|
||||
fi
|
||||
done
|
||||
fg_nb_batt=$(( "$batt_nb" )) # force en numérique
|
||||
[ "$batt_detail" ] && fg_batt=${batt_detail::-1} # suppression dernier $'\n'
|
||||
[ "$(xargs <<< $fg_batt_serial)" ] || fg_batt_serial+="n/a"
|
||||
if [ "$batt_detail" ]; then
|
||||
fg_batt=${batt_detail::-1} # suppression dernier $'\n'
|
||||
fi
|
||||
if [ -z "$(xargs <<< $fg_batt_serial)" ] ; then
|
||||
fg_batt_serial+="n/a"
|
||||
fi
|
||||
}
|
||||
|
||||
# assigne $fg_cpu (description cpu), fg_nb_threads, $fg_cpu_arch, $fg_uarch, $fg_vendor=AMD|Intel, $fg_nb_cpu
|
||||
|
@ -3326,23 +3327,22 @@ figet_lspci(){ # 8/12/2017
|
|||
# indépendant de procps, affichage plus clair que free, mais résultats identiques
|
||||
figet_mem(){ # 9/12/2017
|
||||
local freeDebug MemTotal MemFree MemAvailable Buffers Cached SReclaimable Shmem MemUsed
|
||||
local SwapTotal SwapFree SwapCached col a b
|
||||
local SwapTotal SwapFree SwapCached col a b c MemLibre
|
||||
[ "$2" == "debug" ] && freeDebug="$(free -hw | sed '3d')"
|
||||
IFS=':'
|
||||
while read a b; do
|
||||
[ "$a" == "MemTotal" ] && MemTotal=$(( ${b/kB} )) #echo "$a $((${b/kB}/1024))" ! partie entière !
|
||||
[ "$a" == "MemAvailable" ] && MemAvailable=$(( ${b/kB} ))
|
||||
[ "$a" == "MemFree" ] && MemFree=$(( ${b/kB} ))
|
||||
[ "$a" == "Buffers" ] && Buffers=$(( ${b/kB} ))
|
||||
[ "$a" == "Cached" ] && Cached=$(( ${b/kB} ))
|
||||
[ "$a" == "SReclaimable" ] && SReclaimable=$(( ${b/kB} ))
|
||||
[[ "$a" =~ Shmem$|MemShared$ ]] && Shmem=$(( ${b/kB} )) # = free shared
|
||||
[ "$a" == "SwapTotal" ] && SwapTotal=$(( ${b/kB} ))
|
||||
[ "$a" == "SwapFree" ] && SwapFree=$(( ${b/kB} ))
|
||||
[ "$a" == "SwapCached" ] && SwapCached=$(( ${b/kB} ))
|
||||
while read a b c; do
|
||||
[ "$a" == "MemTotal:" ] && MemTotal="$b" #echo "$a $((${b/kB}/1024))" ! partie entière !
|
||||
[ "$a" == "MemAvailable:" ] && MemAvailable="$b"
|
||||
[ "$a" == "MemFree:" ] && MemFree="$b"
|
||||
[ "$a" == "Buffers:" ] && Buffers="$b"
|
||||
[ "$a" == "Cached:" ] && Cached="$b"
|
||||
[ "$a" == "SReclaimable:" ] && SReclaimable="$b"
|
||||
[[ "$a" =~ Shmem$|MemShared$ ]] && Shmem="$b" # = free shared
|
||||
[ "$a" == "SwapTotal:" ] && SwapTotal="$b"
|
||||
[ "$a" == "SwapFree:" ] && SwapFree="$b"
|
||||
[ "$a" == "SwapCached:" ] && SwapCached="$b"
|
||||
done <<< $(< /proc/meminfo)
|
||||
IFS="$IFS_INI"
|
||||
MemUsed=$(( $MemTotal-($MemFree+$Buffers+$Cached+$SReclaimable) ))
|
||||
MemLibre=$(( $MemFree + $Buffers + $Cached + $SReclaimable ))
|
||||
MemUsed=$(( $MemTotal - $MemLibre ))
|
||||
SwapUsed=$(( $SwapTotal-$SwapFree ))
|
||||
totalTotal=$(( $MemTotal+$SwapTotal ))
|
||||
totalUsed=$(( $MemUsed+$SwapUsed ))
|
||||
|
@ -3996,7 +3996,7 @@ for j in $options; do
|
|||
ORIGIN='test'
|
||||
prg_1 "$*"
|
||||
echo -n "•"
|
||||
fi_system
|
||||
fi_mem
|
||||
echo; f_dspl_md "$fileOutput"
|
||||
exit ;; # test
|
||||
-c* | all )
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# changelog getInfo
|
||||
|
||||
## getInfo 2.59.3 9/12/2017
|
||||
## getInfo 2.59.4 9/12/2017
|
||||
|
||||
* révision: fi_system si plusieurs batteries
|
||||
* fix: figet_batt, protection format numérique
|
||||
|
|
Loading…
Reference in New Issue