<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thinkwiki.org/w/index.php?action=history&amp;feed=atom&amp;title=Code%2Ftp-fancontrol-basic</id>
	<title>Code/tp-fancontrol-basic - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.thinkwiki.org/w/index.php?action=history&amp;feed=atom&amp;title=Code%2Ftp-fancontrol-basic"/>
	<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Code/tp-fancontrol-basic&amp;action=history"/>
	<updated>2026-05-11T17:09:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.12</generator>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Code/tp-fancontrol-basic&amp;diff=62546&amp;oldid=prev</id>
		<title>ThinkGNU: Put script in &lt;pre&gt; block, so it can be copy-pasted</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Code/tp-fancontrol-basic&amp;diff=62546&amp;oldid=prev"/>
		<updated>2025-04-11T07:24:42Z</updated>

		<summary type="html">&lt;p&gt;Put script in &amp;lt;pre&amp;gt; block, so it can be copy-pasted&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 07:24, 11 April 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#!/bin/bash&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#!/bin/bash&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l101&quot; &gt;Line 101:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 102:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; IDX=$NEWIDX&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; IDX=$NEWIDX&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;done&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;done&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key c1thinkwiki:diff::1.12:old-23724:rev-62546 --&gt;
&lt;/table&gt;</summary>
		<author><name>ThinkGNU</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Code/tp-fancontrol-basic&amp;diff=23724&amp;oldid=prev</id>
		<title>Thinker: moved from ACPI fan control script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Code/tp-fancontrol-basic&amp;diff=23724&amp;oldid=prev"/>
		<updated>2006-07-26T21:08:21Z</updated>

		<summary type="html">&lt;p&gt;moved from &lt;a href=&quot;/wiki/ACPI_fan_control_script&quot; class=&quot;mw-redirect&quot; title=&quot;ACPI fan control script&quot;&gt;ACPI fan control script&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# This script dynamically controls fan speed on some ThinkPad models&lt;br /&gt;
# according to user-defined temperature thresholds.  It implements its&lt;br /&gt;
# own decision algorithm, overriding the ThinkPad embedded&lt;br /&gt;
# controller. It also implements a workaround for the fan noise pulse&lt;br /&gt;
# experienced every few seconds on some ThinkPads.&lt;br /&gt;
#&lt;br /&gt;
# The script requires the ibm_acpi patch at &lt;br /&gt;
# http://thinkwiki.org/wiki/Patch_for_controlling_fan_speed&lt;br /&gt;
#&lt;br /&gt;
# WARNING: This script relies on undocumented hardware features and&lt;br /&gt;
# overrides nominal hardware behavior. It may thus cause arbitrary&lt;br /&gt;
# damage to your laptop or data. Watch your temperatures!&lt;br /&gt;
#&lt;br /&gt;
# This file is placed in the public domain and may be freely distributed.&lt;br /&gt;
&lt;br /&gt;
LEVELS=(    0      2      4      7)  # Fan speed levels&lt;br /&gt;
UP_TEMPS=(      52     60     68  )  # Speed increase trip points&lt;br /&gt;
DOWN_TEMPS=(  48     56     64    )  # Speed decrease trip points&lt;br /&gt;
&lt;br /&gt;
ANTIPULSE=( 0      1      0      0)  # Prevent fan pulsing noise at this level&lt;br /&gt;
                                     #   (this also prevents fan speed updates)&lt;br /&gt;
&lt;br /&gt;
IBM_ACPI=/proc/acpi/ibm&lt;br /&gt;
FAN=$IBM_ACPI/fan&lt;br /&gt;
INTERVAL=3&lt;br /&gt;
VERBOSE=true&lt;br /&gt;
DRY_RUN=false&lt;br /&gt;
&lt;br /&gt;
[[ &amp;quot;$1&amp;quot; == &amp;quot;-t&amp;quot; ]] &amp;amp;&amp;amp; { DRY_RUN=true; echo &amp;quot;$0: Dry run, will not change fan state.&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
# Enable the fan in default mode if anything goes wrong:&lt;br /&gt;
set -e -E -u&lt;br /&gt;
$DRY_RUN || trap &amp;quot;echo enable &amp;gt; $FAN; exit 0&amp;quot; EXIT HUP INT ABRT QUIT SEGV TERM&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
thermometer() { # output list of temperatures&lt;br /&gt;
    read X Y &amp;lt; $IBM_ACPI/thermal&lt;br /&gt;
    [[ &amp;quot;$X&amp;quot; == &amp;quot;temperatures:&amp;quot; ]] || { &lt;br /&gt;
	echo &amp;quot;$0: Bad temperatures: $X $Y&amp;quot; &amp;gt;&amp;amp;2 &lt;br /&gt;
	exit 1&lt;br /&gt;
    }&lt;br /&gt;
    echo &amp;quot;$Y&amp;quot;; &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
speedometer() { # output fan speed&lt;br /&gt;
    cat $FAN | sed '/^speed/!d; s/speed:[ \t]*//'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
IDX=0&lt;br /&gt;
MAX_IDX=$(( ${#LEVELS[@]} - 1 ))&lt;br /&gt;
SETTLE=0&lt;br /&gt;
&lt;br /&gt;
while true; do&lt;br /&gt;
    TEMPS=`thermometer`&lt;br /&gt;
    $VERBOSE &amp;amp;&amp;amp; SPEED=`speedometer`&lt;br /&gt;
&lt;br /&gt;
    # Calculate new level&lt;br /&gt;
    NEWIDX=$IDX&lt;br /&gt;
    DOWN=$(( IDX &amp;gt; 0 ))&lt;br /&gt;
    for TEMP in $TEMPS; do&lt;br /&gt;
        # Increase speed as much as needed&lt;br /&gt;
        while [[ $NEWIDX -lt $MAX_IDX ]] &amp;amp;&amp;amp; &lt;br /&gt;
              [[ $TEMP -ge ${UP_TEMPS[$NEWIDX]} ]]; do&lt;br /&gt;
            (( NEWIDX ++ ))&lt;br /&gt;
            DOWN=0&lt;br /&gt;
        done&lt;br /&gt;
        # Allow decrease (by one index)?&lt;br /&gt;
        if [[ $DOWN == 1 ]] &amp;amp;&amp;amp; &lt;br /&gt;
           [[ $TEMP -gt ${DOWN_TEMPS[$(( IDX - 1 ))]} ]]; then&lt;br /&gt;
            DOWN=0&lt;br /&gt;
        fi&lt;br /&gt;
    done&lt;br /&gt;
    if [[ $DOWN == 1 ]]; then&lt;br /&gt;
        NEWIDX=$(( IDX - 1 ))&lt;br /&gt;
    fi&lt;br /&gt;
&lt;br /&gt;
    # Transition&lt;br /&gt;
    OLDLEVEL=${LEVELS[$IDX]}&lt;br /&gt;
    NEWLEVEL=${LEVELS[$NEWIDX]}&lt;br /&gt;
    $VERBOSE &amp;amp;&amp;amp; echo &amp;quot;tpfan: Temps: $TEMPS   Fan: $SPEED   Level: $OLDLEVEL-&amp;gt;$NEWLEVEL&amp;quot;&lt;br /&gt;
    $DRY_RUN || echo level $NEWLEVEL &amp;gt; $FAN&lt;br /&gt;
&lt;br /&gt;
    sleep $INTERVAL&lt;br /&gt;
&lt;br /&gt;
    # If needed, apply anti-pulsing hack after a settle-down period:&lt;br /&gt;
    if [[ ${ANTIPULSE[${NEWIDX}]} == 1 ]]; then&lt;br /&gt;
	if [[ $NEWLEVEL == $OLDLEVEL ]]; then&lt;br /&gt;
	    if [[ $SETTLE -ge 0 ]]; then&lt;br /&gt;
		(( SETTLE -= INTERVAL ))&lt;br /&gt;
	    else&lt;br /&gt;
		$DRY_RUN || echo level disengaged &amp;gt;&amp;gt; $FAN&lt;br /&gt;
		sleep 0.5&lt;br /&gt;
	    fi&lt;br /&gt;
	else&lt;br /&gt;
	    SETTLE=6&lt;br /&gt;
	fi&lt;br /&gt;
    fi&lt;br /&gt;
&lt;br /&gt;
    IDX=$NEWIDX&lt;br /&gt;
done&lt;/div&gt;</summary>
		<author><name>Thinker</name></author>
		
	</entry>
</feed>