---
- include_tasks: tlp.yml
  when: power_management is defined and power_management == "tlp"

- include_tasks: tuned.yml
  when: power_management is defined and power_management == "tuned"

- include_tasks: framework.yml
  when: power_management is defined and power_management == "tuned" and ansible_system_vendor == "Framework"

- name: Install x86_energy_perf_policy
  pacman:
    name: x86_energy_perf_policy
    state: present

- name: Copy touchpad configuration file
  copy:
    src: 30-touchpad.conf
    dest: /etc/X11/xorg.conf.d/30-touchpad.conf
  tags:
    - libinput

- name: Copy logind configuration file
  copy:
    src: logind.conf
    dest: /etc/systemd/logind.conf

- name: Install poweralertd
  kewlfft.aur.aur:
    name: poweralertd
  become: yes
  become_user: "{{ aur.user }}"
  tags:
    - aur

- name: Enable and start poweralertd
  systemd:
    name: poweralertd.service
    scope: user
    enabled: yes
    state: started
  become: yes
  become_user: "{{ user.name }}"
  environment:
    XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
  tags:
    - aur

- name: Install powertop
  pacman:
    name: powertop
    state: present

- name: Install powerstat
  kewlfft.aur.aur:
    name: powerstat
  become: yes
  become_user: "{{ aur.user }}"
  tags:
    - aur

- name: Install cmake for battery-stats
  pacman:
    name: cmake
    state: present

- name: Install battery-stats
  kewlfft.aur.aur:
    name: battery-stats-git
  become: yes
  become_user: "{{ aur.user }}"
  tags:
    - aur

- name: Install battop
  kewlfft.aur.aur:
    name: battop
  become: yes
  become_user: "{{ aur.user }}"
  tags:
    - aur
