ArchLinux:Shell
From Wiki.cyring.fr
(Difference between revisions)
(Created page with "===== Bash script to read ASUS sensors ===== <br /> http://blog.cyring.fr/wp-content/uploads/2010/10/Sensors.png <br /><br /> <syntaxhighlight lang="bash"> $ nano ~/.bashrc </...") |
|||
Line 9: | Line 9: | ||
function chipset () | function chipset () | ||
{ | { | ||
+ | local hwpath="/sys/class/hwmon/hwmon2" | ||
+ | |||
local Dev="all" | local Dev="all" | ||
case "${1}" in | case "${1}" in | ||
Line 29: | Line 31: | ||
declare -i I=1 | declare -i I=1 | ||
- | while [ -e | + | while [ -e ${hwpath}/${Dev}${I}_label ]; |
do | do | ||
- | local Label=$(cat | + | local Label=$(cat ${hwpath}/${Dev}${I}_label) |
- | local Input=$(cat | + | local Input=$(cat ${hwpath}/${Dev}${I}_input) |
- | local Min=$(cat | + | local Min=$(cat ${hwpath}/${Dev}${I}_${Label1}) |
- | local Max=$(cat | + | local Max=$(cat ${hwpath}/${Dev}${I}_${Label2}) |
local Padding="" | local Padding="" |
Revision as of 15:58, 30 April 2012
Bash script to read ASUS sensors
$ nano ~/.bashrc
function chipset ()
{
local hwpath="/sys/class/hwmon/hwmon2"
local Dev="all"
case "${1}" in
( fan | FAN )
Label1="min"
Label2="max"
Dev="fan" ;;
( temp | temperature | TEMP | TEMPERATURE )
Label1="max"
Label2="crit"
Dev="temp" ;;
( volt | voltage | VOLT | VOLTAGE )
Label1="min"
Label2="max"
Dev="in" ;;
( * )
echo "Usage: $FUNCNAME [FAN] [TEMP] [VOLT]"
return 1 ;;
esac
declare -i I=1
while [ -e ${hwpath}/${Dev}${I}_label ];
do
local Label=$(cat ${hwpath}/${Dev}${I}_label)
local Input=$(cat ${hwpath}/${Dev}${I}_input)
local Min=$(cat ${hwpath}/${Dev}${I}_${Label1})
local Max=$(cat ${hwpath}/${Dev}${I}_${Label2})
local Padding=""
declare -i Len=${#Label}
for (( L=${Len}; L<32; L++ ));
do
Padding=${Padding}" "
done
echo -e "${Label}${Padding}${Input}\t[ ${Min} - ${Max} ]";
I=I+1
done
}