Blog Code Forum

ArchLinux:Shell

From Wiki.cyring.fr

(Difference between revisions)
Jump to: navigation, search
(Bash script to read ASUS sensors)
 
Line 7: Line 7:
</syntaxhighlight><br />
</syntaxhighlight><br />
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
 +
export EDITOR=nano
 +
 +
alias p='ps -eo user:5,pid:6,pcpu:5,rss:7,nlwp:2,comm --sort +pcpu,+rss'
 +
function chipset ()
function chipset ()
{
{

Latest revision as of 11:56, 24 December 2013

Bash script to read ASUS sensors


Sensors.png

$ nano ~/.bashrc

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