2 # A simple configuration gui for eee-fan-control.sh
3 ## yet another dubious Dougal script for Puppy Linux, Oct. 22nd 2008
4 ## Licenced under GPL v2 or later
5 ## No BASHisms I'm aware of...
6 # Update Nov. 2nd: add VERBOSE_LOGGING and mention MAX_ and MIN_ temps
8 SCRIPT_NAME
="eee-fan-ctrl.sh"
9 CONFIG_FILE
="/etc/eee-fan.conf"
10 LOG_FILE
="/var/log/eee-fan.log"
11 # a list of the variables in the config file (so we can set the defaults in the gui)
12 VARIABLES
="CONTROL_FAN SLEEP_TIME HIGH_TEMP LOW_TEMP FAN_SPEED ENABLE_LOGGING VERBOSE_LOGGING"
13 # a list of the variables that get shaded if control is set to "false"...
14 SHADEABLES
="SLEEP_TIME HIGH_TEMP LOW_TEMP FAN_SPEED ENABLE_LOGGING VERBOSE_LOGGING"
16 ## A function to kill stray processes (sometimes remain if dialog closed by WM)
17 ## dialog variable passed as param
20 for I
in $
( ps
-eo pid
,command |
grep "$1" |
grep -v grep |
grep -F 'gtkdialog3' | cut
-d' ' -f1 )
28 # set defaults for gtkdialog (and so we know if the value was changed...)
30 do eval DEFAULT_
$ONE=\$
$ONE
33 # set the default visibility
34 if [ "$CONTROL_FAN" = "true" ] ; then
35 for ONE
in $SHADEABLES
36 do eval VISIBLE_
$ONE=\"\
<visible\
>enabled\
<\
/visible\
>\"
39 for ONE
in $SHADEABLES
40 do eval VISIBLE_
$ONE=\"\
<visible\
>disabled\
<\
/visible\
>\"
44 # create the block of if commands for (un)shading fields
46 for ONE
in $SHADEABLES
48 CONTROL_FAN_CODE
="$CONTROL_FAN_CODE
49 <action>if false disable:$ONE</action>
50 <action>if true enable:$ONE</action>"
53 export EEE_FAN_CONFIG_GUI
="<window title=\"Eee Fan Control Configuration\" icon-name=\"gtk-preferences\" window-position=\"1\">
56 <label>\"Control the fan manually?\"</label>
57 <variable>CONTROL_FAN</variable>
58 <default>$DEFAULT_CONTROL_FAN</default>
64 <label>How frequently we should check the temperature (in seconds)?</label>
67 <variable>SLEEP_TIME</variable>
68 <default>$DEFAULT_SLEEP_TIME</default>
73 <frame Operating Temperature Range >
74 <text use-markup=\"true\">
75 <label>\"The temperature range in which the fan should be active:
76 When the temperature reaches the 'High temp', the fan will be activated and remain active until the temperature gets down to the 'Low temp'. (Temperatures are in centigrade/Celsius.)
77 <i>Note: The daemon only accepts values in the range $MIN_TEMP-$MAX_TEMP.</i>\"</label>
81 <label>High temp:</label>
84 <variable>HIGH_TEMP</variable>
85 <default>$DEFAULT_HIGH_TEMP</default>
90 <label>Low temp:</label>
93 <variable>LOW_TEMP</variable>
94 <default>$DEFAULT_LOW_TEMP</default>
101 <label>The speed to run the fan at (0-100):</label>
104 <variable>FAN_SPEED</variable>
105 <default>$DEFAULT_FAN_SPEED</default>
109 <frame Logging support (log file $LOG_FILE) >
111 <label>Enable logging? (log any status changes)</label>
112 <variable>ENABLE_LOGGING</variable>
113 <default>$DEFAULT_ENABLE_LOGGING</default>
114 $VISIBLE_ENABLE_LOGGING
117 <label>Verbose logging? (log the temperature every time we check it)</label>
118 <variable>VERBOSE_LOGGING</variable>
119 <default>$DEFAULT_VERBOSE_LOGGING</default>
120 $VISIBLE_VERBOSE_LOGGING
124 <label>Apply now (rather tnat next time script is started)?</label>
125 <variable>APPLY_NOW</variable>
126 <default>true</default>
130 <button cancel></button>
136 for STATEMENT
in $
(gtkdialog
--program EEE_FAN_CONFIG_GUI
); do
137 eval $STATEMENT 2>/dev
/null
140 clean_up_gtkdialog EEE_FAN_CONFIG_GUI
141 unset EEE_FAN_CONFIG_GUI
143 case $EXIT in OK
) ;; *) exit ;; esac
145 # see if anything has changed
146 for ONE
in $VARIABLES
148 eval OLD
=\
$DEFAULT_$ONE
150 if [ "$NEW" != "$OLD" ] ; then
151 # make sure the new value is not blank!
152 [ "$NEW" ] ||
continue
153 sed -i "s/^$ONE=.*/$ONE=$NEW/" "$CONFIG_FILE"
157 # see if we want to apply immediately
158 $APPLY_NOW && killall
-q -HUP $SCRIPT_NAME