diff --git a/roles/laptop/tasks/asusctl.yml b/roles/laptop/tasks/asusctl.yml index e94ab7b..80bd017 100644 --- a/roles/laptop/tasks/asusctl.yml +++ b/roles/laptop/tasks/asusctl.yml @@ -26,8 +26,8 @@ target: install - name: "Enable service" - ansible.builtin.systemd: become: yes + ansible.builtin.systemd: name: asusctl state: started enabled: yes \ No newline at end of file diff --git a/roles/laptop/tasks/battery.yml b/roles/laptop/tasks/battery.yml index c6ad9bb..04d25f4 100644 --- a/roles/laptop/tasks/battery.yml +++ b/roles/laptop/tasks/battery.yml @@ -1,18 +1,11 @@ -- name: Check if laptop has option to limit battery - stat: - path: /sys/class/power_supply/BAT0/charge_control_end_threshold - register: battery_limiter_available +- 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 -- 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 +- name: Enable battery limit service + become: yes + systemd: + name: battery-charge-threshold + enabled: yes diff --git a/roles/laptop/tasks/main.yml b/roles/laptop/tasks/main.yml index 3b06788..cf3250e 100644 --- a/roles/laptop/tasks/main.yml +++ b/roles/laptop/tasks/main.yml @@ -1,5 +1,10 @@ -- import_tasks: battery.yml +- name: Check if it's laptop + stat: + path: /sys/class/power_supply/BAT0/charge_control_end_threshold + register: battery_limiter_available -- import_tasks: asusctl.yml - -- import_tasks: supergfxctl.yml +- when: battery_limiter_available.stat.exists + block: + - import_tasks: battery.yml + - import_tasks: asusctl.yml + - import_tasks: supergfxctl.yml diff --git a/roles/laptop/tasks/supergfxctl.yml b/roles/laptop/tasks/supergfxctl.yml index 5c9523d..3cddd0b 100644 --- a/roles/laptop/tasks/supergfxctl.yml +++ b/roles/laptop/tasks/supergfxctl.yml @@ -26,8 +26,8 @@ target: install - name: "Enable service" - ansible.builtin.systemd: become: yes + ansible.builtin.systemd: name: asusctl state: started enabled: yes \ No newline at end of file