Add battery charge limiter for laptop
This commit is contained in:
parent
107f7aa27d
commit
a36600126b
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Set the battery charge threshold
|
||||||
|
After=multi-user.target
|
||||||
|
StartLimitBurst=0
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Restart=on-failure
|
||||||
|
ExecStart=/bin/bash -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
18
roles/laptop/tasks/battery.yml
Normal file
18
roles/laptop/tasks/battery.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
- 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
|
1
roles/laptop/tasks/main.yml
Normal file
1
roles/laptop/tasks/main.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
- import_tasks: battery.yml
|
Loading…
Reference in New Issue
Block a user