ansible-desktop/roles/laptop/tasks/battery.yml

19 lines
568 B
YAML
Raw Normal View History

2022-07-14 19:06:42 +00:00
- name: Check if laptop has option to limit battery
stat:
path: /sys/class/power_supply/BAT0/charge_control_end_threshold
register: battery_limiter_available
- when: battery_limiter_available.stat.exists
block:
- name: Copy service to limit battery charge
become: yes
copy:
src: lib/systemd/system/battery-charge-threshold.service
dest: /lib/systemd/system/battery-charge-threshold.service
- name: Enable battery limit service
become: yes
systemd:
name: battery-charge-threshold
enabled: yes