Skip to content

Commit

Permalink
feat(power) replace mbpfan with thermald
Browse files Browse the repository at this point in the history
references #12
  • Loading branch information
jeremiehuchet committed May 15, 2018
1 parent f1a4206 commit bede3a9
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 25 deletions.
43 changes: 27 additions & 16 deletions roles/system/tasks/powermanagement.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
- name: install sensors reader
- name: install power management tools
package:
name: lm_sensors
name: "{{ item }}"
state: present
with_items:
- lm_sensors
- thermald
become: yes

- name: create thermald service unit override dir
file:
path: /etc/systemd/system/thermald.service.d
state: directory
mode: 0755
become: yes

- name: check AUR package 'mbpfan-git' is installed
stat:
path: /usr/bin/mbpfan
register: mbpfan
failed_when: mbpfan.stat.exists == False
- name: override thermald service unit
template:
src: thermald/thermald.service.override.conf
dest: /etc/systemd/system/thermald.service.d/override.conf
mode: 0444
become: yes

- name: configure fan control service
- name: configure thermald
template:
src: mbpfan.conf
dest: /etc/mbpfan.conf
src: thermald/thermal-conf.xml
dest: /etc/thermald/thermal-conf.xml
mode: 0444
register: mbpfan
register: thermald_conf
become: yes

- name: restart fan control service on config change
- name: restart thermald on config change
service:
name: mbpfan
name: thermald
state: restarted
when: mbpfan.changed
when: thermald_conf.changed
become: yes

- name: enable fan control service
- name: enable thermaldservice
service:
name: mbpfan
name: thermald
state: started
enabled: yes
become: yes
Expand Down
9 changes: 0 additions & 9 deletions roles/system/templates/mbpfan.conf

This file was deleted.

59 changes: 59 additions & 0 deletions roles/system/templates/thermald/thermal-conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!-- {{ generated_tag }} -->
<ThermalConfiguration>
<Platform>
<Name>Override default passive</Name>
<ProductName>*</ProductName>
<ThermalZones>
<ThermalZone>
<Type>cpu</Type>
<TripPoints>
<TripPoint>
<Temperature>78000</Temperature>
<type>passive</type>
</TripPoint>
</TripPoints>
</ThermalZone>
<ThermalZone>
<Type>frame</Type>
<TripPoints>
<TripPoint>
<SensorType>x86_pkg_temp</SensorType>
<Temperature>78000</Temperature>
<type>passive</type>
<ControlType>PARALLEL</ControlType>
<CoolingDevice>
<Type>macbook_left_fan</Type>
<Influence>50</Influence>
<SamplingPeriod>12</SamplingPeriod>
</CoolingDevice>
<CoolingDevice>
<Type>macbook_right_fan</Type>
<Influence>50</Influence>
<SamplingPeriod>12</SamplingPeriod>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
</ThermalZones>
<CoolingDevices>
<CoolingDevice>
<Type>macbook_left_fan</Type>
<Path>/sys/devices/platform/applesmc.768/fan1_output</Path>
<MinState>2160</MinState>
<IncDecStep>500</IncDecStep>
<ReadBack>0</ReadBack>
<MaxState>6156</MaxState>
<DebouncePeriod>5</DebouncePeriod>
</CoolingDevice>
<CoolingDevice>
<Type>macbook_right_fan</Type>
<Path>/sys/devices/platform/applesmc.768/fan2_output</Path>
<MinState>2000</MinState>
<IncDecStep>500</IncDecStep>
<ReadBack>0</ReadBack>
<MaxState>5700</MaxState>
<DebouncePeriod>5</DebouncePeriod>
</CoolingDevice>
</CoolingDevices>
</Platform>
</ThermalConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# {{ generated_tag }}
[Service]
ExecStartPre=/bin/sh -c 'echo 1 > /sys/devices/platform/applesmc.768/fan1_manual'
ExecStartPre=/bin/sh -c 'echo 1 > /sys/devices/platform/applesmc.768/fan2_manual'
ExecStopPost=/bin/sh -c 'echo 0 > /sys/devices/platform/applesmc.768/fan1_manual'
ExecStopPost=/bin/sh -c 'echo 0 > /sys/devices/platform/applesmc.768/fan2_manual'

0 comments on commit bede3a9

Please sign in to comment.