--- /usr/sbin/fancontrol	2011-01-11 05:48:53.975019348 +0300
+++ /usr/local/bin/fancontrol	2011-01-17 01:53:17.783813757 +0300
@@ -66,6 +66,7 @@
 	FCFANS=`egrep '^FCFANS=.*$' $1 | sed -e 's/FCFANS=//g'`
 	MINPWM=`egrep '^MINPWM=.*$' $1 | sed -e 's/MINPWM=//g'`
 	MAXPWM=`egrep '^MAXPWM=.*$' $1 | sed -e 's/MAXPWM=//g'`
+	CMDS=`egrep '^CMDS=.*$' $1 | sed -e 's/CMDS=//g'`
 
 	# Check whether all mandatory settings are set
 	if [[ -z ${INTERVAL} || -z ${FCTEMPS} || -z ${MINTEMP} || -z ${MAXTEMP} || -z ${MINSTART} || -z ${MINSTOP} ]]
@@ -80,6 +81,14 @@
 		exit 1
 	fi
 
+	if [[ -n ${CMDS} ]]
+	then
+		temp=$IFS
+		IFS=$'\n'
+		CMDS=($(echo $CMDS | awk '{i=split($0, cmds, " // "); for (j=1; j<=i; j++) print (cmds[j]) }'))
+		IFS=$temp
+	fi
+
 	# write settings to arrays for easier use and print them
 	echo
 	echo "Common settings:"
@@ -225,10 +234,20 @@
 	while (( $fcvcount < ${#AFCTEMP[@]} )) # go through all temp inputs
 	do
 		tsen=${AFCTEMP[$fcvcount]}
-		if [ ! -r $tsen ]
-		then
-			echo "Error: file $tsen doesn't exist"
-			outdated=1
+		if `echo ${tsen} | grep -qP '^CMD\d+'`
+ 		then
+			index=`echo ${tsen} | cut -b 4-`
+			if [ -z ${CMDS[$index]} ]
+			then
+				echo "Error: command #$index is not defined"
+				outdated=1
+			fi
+		else
+			if [ ! -r $tsen ]
+			then
+				echo "Error: file $tsen doesn't exist"
+				outdated=1
+			fi
 		fi
 		let fcvcount=$fcvcount+1
 	done
@@ -388,11 +407,24 @@
 		minpwm=${AFCMINPWM[$fcvcount]}
 		maxpwm=${AFCMAXPWM[$fcvcount]}
 
-		read tval < ${tsens}
-		if [ $? -ne 0 ]
-		then
-			echo "Error reading temperature from $DIR/$tsens"
-			restorefans 1
+		if `echo ${tsens} | grep -qP '^CMD\d+'`
+ 		then
+			index=`echo ${tsens} | cut -b 4-`
+			tval=`${CMDS[$index]}`
+			if [ -z $tval ]
+			then
+				echo "Error reading temperature using command #$index"
+				restorefans 1
+			else
+				let tval="${tval}*1000"
+			fi
+ 		else
+			read tval < ${tsens}
+			if [ $? -ne 0 ]
+			then
+				echo "Error reading temperature from $DIR/$tsens"
+				restorefans 1
+			fi
 		fi
 
 		read pwmpval < ${pwmo}
