Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Fan-Control-Daemon
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CeRiAl
Fan-Control-Daemon
Commits
6ea021ad
Commit
6ea021ad
authored
Jul 04, 2012
by
CeRiAl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for configfile /etc/mbpfan.conf
parent
1b84085a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
13 deletions
+95
-13
AUTHORS
AUTHORS
+4
-4
Makefile
Makefile
+20
-2
mbpfan.conf
mbpfan.conf
+7
-0
daemon.c
src/daemon.c
+4
-3
mbpfan.c
src/mbpfan.c
+60
-4
No files found.
AUTHORS
View file @
6ea021ad
...
...
@@ -2,7 +2,7 @@ MAINTAINERS AND CONTRIBUTORS
----------------------------
Daniel Graziotin <dgraziotin AT task3 DOT cc>
CeRiAl <ikhatib AT imail DOT de
>
Ismail Khatib <ikhatib AT gmail DOT com
>
ORIGINARY AUTHORS
...
...
Makefile
View file @
6ea021ad
...
...
@@ -5,6 +5,7 @@ C = c
OUTPUT_PATH
=
bin/
SOURCE_PATH
=
src/
EXE
=
bin/mbpfan
CONF
=
mbpfan.conf
ifeq
($(COMPILER),
G++)
ifeq
($(OS),Windows_NT)
...
...
@@ -55,12 +56,29 @@ clean:
install
:
cp
$(EXE)
/usr/sbin
cp
-n
$(CONF)
/etc
@
echo
"-----------------------------------------------------------------------------"
@
echo
"An init file suitable for /lib/lsb/init-functions (Debian & Ubuntu f
u
r sure)"
@
echo
"
Is located in the main folder of the source files. It is called mbpfan.init.
"
@
echo
"An init file suitable for /lib/lsb/init-functions (Debian & Ubuntu f
o
r sure)"
@
echo
"
is located in the main folder of the source files, called mbpfan.init.debian
"
@
echo
"Rename it to mbpfan, give it execution permissions (chmod +x mbpfan)"
@
echo
"and move it to /etc/init.d"
@
echo
"Then, add it to the default runlevels with sudo update-rc.d mbpfan defaults"
@
echo
""
@
echo
"Additionally, an init file suitable for /etc/rc.d/init.d/functions"
@
echo
"(RHEL/CentOS & Fedora) is also located at the same place, this file is called"
@
echo
"mbpfan.init.redhat. Also rename it to mbpfan, give it execution permissions"
@
echo
"and move it to /etc/init.d"
@
echo
"To add the script to the default runlevels, run the following as root:"
@
echo
"chkconfig --level 2345 mbpfan on && chkconfig --level 016 mbpfan off"
@
echo
""
@
echo
"As a special bonus, a service file for systemd is also included. To use it,"
@
echo
"execute the following as root:"
@
echo
"cp mbpfan.service /usr/lib/systemd/system"
@
echo
"ln -s /usr/lib/systemd/system/mbpfan.service /etc/systemd/system/mbpfan.service"
@
echo
"systemctl daemon-reload"
@
echo
"systemctl start mbpfan.service"
@
echo
"To start the service automatically at boot, also execute the following:"
@
echo
"systemctl enable mbpfan.service"
@
echo
"-----------------------------------------------------------------------------"
rebuild
:
clean all
...
...
mbpfan.conf
0 → 100644
View file @
6ea021ad
[
general
]
min_fan_speed
=
2000
# default is 2000
max_fan_speed
=
6200
# default is 6200
low_temp
=
63
# try ranges 55-63, default is 63
high_temp
=
66
# try ranges 58-66, default is 66
max_temp
=
86
# do not set it > 90, default is 86
polling_interval
=
7
# default is 7
src/daemon.c
View file @
6ea021ad
/**
* Copyright (C) 2012 Peter Lombardo <http://peterlombardo.wikidot.com/linux-daemon-in-c>
* Modifications (2012) by Daniel Graziotin <dgraziotin@task3.cc>
* Modifications (2012) by Ismail Khatib <ikhatib@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -162,7 +163,7 @@ void go_daemon(void (*fan_control)())
{
if
(
verbose
)
{
printf
(
"Writing a new .pid file with value %d at: %s"
,
current_pid
,
program_pid
);
printf
(
"Writing a new .pid file with value %d at: %s
\n
"
,
current_pid
,
program_pid
);
syslog
(
LOG_INFO
,
"Writing a new .pid file with value %d at: %s"
,
current_pid
,
program_pid
);
}
if
(
write_pid
(
current_pid
)
==
0
)
...
...
@@ -170,7 +171,7 @@ void go_daemon(void (*fan_control)())
syslog
(
LOG_ERR
,
"Can not create a .pid file at: %s. Aborting"
,
program_pid
);
if
(
verbose
)
{
printf
(
"ERROR: Can not create a .pid file at: %s. Aborting"
,
program_pid
);
printf
(
"ERROR: Can not create a .pid file at: %s. Aborting
\n
"
,
program_pid
);
}
exit
(
EXIT_FAILURE
);
}
...
...
@@ -178,7 +179,7 @@ void go_daemon(void (*fan_control)())
{
if
(
verbose
)
{
printf
(
"Successfully written a new .pid file with value %d at: %s"
,
current_pid
,
program_pid
);
printf
(
"Successfully written a new .pid file with value %d at: %s
\n
"
,
current_pid
,
program_pid
);
syslog
(
LOG_INFO
,
"Successfully written a new .pid file with value %d at: %s"
,
current_pid
,
program_pid
);
}
}
...
...
src/mbpfan.c
View file @
6ea021ad
...
...
@@ -3,6 +3,7 @@
* Copyright (C) 2010 Allan McRae <allan@archlinux.org>
* Modifications by Rafael Vega <rvega@elsoftwarehamuerto.org>
* Modifications (2012) by Daniel Graziotin <dgraziotin@task3.cc>
* Modifications (2012) by Ismail Khatib <ikhatib@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -24,7 +25,8 @@
*
* Tested models:
* MacBook Pro 8.1 13" (Intel i7 - Linux 3.2)
* Macbook Pro 6,2 15" (Intel i7 - Linux 3.2)
* MacBook Pro 6,2 15" (Intel i7 - Linux 3.2)
* MacBook Pro 2,2 15" (Intel Core 2 Duo - Linux 3.4.4)
*/
...
...
@@ -36,6 +38,7 @@
#include <syslog.h>
#include "mbpfan.h"
#include "global.h"
#include "settings.h"
/* lazy min/max... */
#define min(a,b) a < b ? a : b
...
...
@@ -273,6 +276,9 @@ void mbpfan()
int
old_temp
,
new_temp
,
fan_speed
,
steps
;
int
temp_change
;
int
step_up
,
step_down
;
FILE
*
f
=
NULL
;
Settings
*
settings
=
NULL
;
int
result
=
0
;
t_sensors
*
sensors
=
retrieve_sensors
();
set_fans_man
(
sensors
);
...
...
@@ -280,12 +286,62 @@ void mbpfan()
fan_speed
=
2000
;
set_fan_speed
(
sensors
,
fan_speed
);
f
=
fopen
(
"/etc/mbpfan.conf"
,
"r"
);
if
(
f
==
NULL
)
{
/* Could not open configfile */
if
(
verbose
)
{
printf
(
"Couldn't open configfile, using defaults
\n
"
);
if
(
daemonize
)
{
syslog
(
LOG_INFO
,
"Couldn't open configfile, using defaults"
);
}
}
}
else
{
settings
=
settings_open
(
f
);
fclose
(
f
);
if
(
settings
==
NULL
)
{
/* Could not read configfile */
if
(
verbose
)
{
printf
(
"Couldn't read configfile
\n
"
);
if
(
daemonize
)
{
syslog
(
LOG_INFO
,
"Couldn't read configfile"
);
}
}
}
else
{
/* Read configfile values */
result
=
settings_get_int
(
settings
,
"general"
,
"min_fan_speed"
);
if
(
result
!=
0
)
min_fan_speed
=
result
;
result
=
settings_get_int
(
settings
,
"general"
,
"max_fan_speed"
);
if
(
result
!=
0
)
max_fan_speed
=
result
;
result
=
settings_get_int
(
settings
,
"general"
,
"low_temp"
);
if
(
result
!=
0
)
low_temp
=
result
;
result
=
settings_get_int
(
settings
,
"general"
,
"high_temp"
);
if
(
result
!=
0
)
high_temp
=
result
;
result
=
settings_get_int
(
settings
,
"general"
,
"max_temp"
);
if
(
result
!=
0
)
max_temp
=
result
;
result
=
settings_get_int
(
settings
,
"general"
,
"polling_interval"
);
if
(
result
!=
0
)
polling_interval
=
result
;
/* Destroy the settings object */
settings_delete
(
settings
);
}
}
if
(
verbose
)
{
printf
(
"Sleeping for %d seconds
\n
"
,
polling_interval
);
if
(
daemonize
)
{
syslog
(
LOG_INFO
,
"Sleeping for %d seconds
\n
"
,
polling_interval
);
syslog
(
LOG_INFO
,
"Sleeping for %d seconds"
,
polling_interval
);
}
}
sleep
(
polling_interval
);
...
...
@@ -330,7 +386,7 @@ void mbpfan()
printf
(
"Old Temp %d: New Temp: %d, Fan Speed: %d
\n
"
,
old_temp
,
new_temp
,
fan_speed
);
if
(
daemonize
)
{
syslog
(
LOG_INFO
,
"Old Temp %d: New Temp: %d, Fan Speed: %d
\n
"
,
old_temp
,
new_temp
,
fan_speed
);
syslog
(
LOG_INFO
,
"Old Temp %d: New Temp: %d, Fan Speed: %d"
,
old_temp
,
new_temp
,
fan_speed
);
}
}
...
...
@@ -341,7 +397,7 @@ void mbpfan()
printf
(
"Sleeping for %d seconds
\n
"
,
polling_interval
);
if
(
daemonize
)
{
syslog
(
LOG_INFO
,
"Sleeping for %d seconds
\n
"
,
polling_interval
);
syslog
(
LOG_INFO
,
"Sleeping for %d seconds"
,
polling_interval
);
}
}
sleep
(
polling_interval
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment