- name: Install power management laptop software
  community.general.pacman:
    name:
      - tlp
      - acpi
      - smartmontools
      - ethtool
    state: present

- name: Install wireless software
  community.general.pacman:
    name:
      - iwd
      - bluez
      - bluez-utils
    state: present

- name: Disable USB autosuspend in tlp
  replace:
    path: /etc/tlp.conf
    regexp: '{{ item.regexp }}'
    replace: '{{ item.replace }}'
  with_items:
    - { regexp: '^#USB_AUTOSUSPEND=1$', replace: 'USB_AUTOSUSPEND=0' }

- name: Create iwd config directory
  ansible.builtin.file:
    path: /etc/iwd
    state: directory
    owner: root
    group: root

- name: Copy iwd config
  ansible.builtin.copy:
    src: iwd.conf
    dest: /etc/iwd/main.conf
    owner: root
    group: root
    mode: "0644"

- name: Enable tlp service
  ansible.builtin.systemd:
    name: tlp
    enabled: True

- name: Enabling iwd service
  ansible.builtin.systemd:
    name: iwd
    enabled: True

- name: Enabling bluetooth service
  ansible.builtin.systemd:
    name: bluetooth
    enabled: True

- name: Copy libinput config
  ansible.builtin.copy:
    src: 30-touchpad.conf
    dest: /etc/X11/xorg.conf.d/30-touchpad.conf
    mode: "0644"


- name: Copy swappiness config
  ansible.builtin.copy:
    src: 99-swappiness.conf
    dest: /etc/sysctl.d/99-swappiness.conf
    mode: "0644"
