Blog Code Forum

ArchLinux:Shell

From Wiki.cyring.fr

(Difference between revisions)
Jump to: navigation, search
Cyril (Talk | contribs)
(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 </...")
Newer edit →

Revision as of 14:44, 6 April 2012

Bash script to read ASUS sensors


Sensors.png

$ nano ~/.bashrc

  1. function chipset ()
  2. {
  3.   local Dev="all"
  4.   case "${1}" in
  5.     ( fan | FAN )
  6.       Label1="min"
  7.       Label2="max"
  8.       Dev="fan" ;;
  9.     ( temp | temperature | TEMP | TEMPERATURE )
  10.       Label1="max"
  11.       Label2="crit"
  12.       Dev="temp" ;;
  13.     ( volt | voltage | VOLT | VOLTAGE )
  14.       Label1="min"
  15.       Label2="max"
  16.       Dev="in" ;;
  17.     ( * )
  18.       echo "Usage: $FUNCNAME [FAN] [TEMP] [VOLT]"
  19.       return 1 ;;
  20.   esac
  21.  
  22.   declare -i I=1
  23.   while [ -e /sys/class/hwmon/hwmon1/${Dev}${I}_label ];
  24.     do
  25.       local Label=$(cat /sys/class/hwmon/hwmon1/${Dev}${I}_label)
  26.       local Input=$(cat /sys/class/hwmon/hwmon1/${Dev}${I}_input)
  27.       local Min=$(cat /sys/class/hwmon/hwmon1/${Dev}${I}_${Label1})
  28.       local Max=$(cat /sys/class/hwmon/hwmon1/${Dev}${I}_${Label2})
  29.  
  30.       local Padding=""
  31.       declare -i Len=${#Label}
  32.       for (( L=${Len}; L<32; L++ ));
  33.         do
  34.           Padding=${Padding}" "
  35.         done
  36.  
  37.       echo -e "${Label}${Padding}${Input}\t[ ${Min} - ${Max} ]";
  38.  
  39.       I=I+1
  40.   done
  41. }
Personal tools