---
- name: Install bluetooth libraries and tools
  pacman:
    name:
      - bluez
      - bluez-libs
      - bluez-utils
      - blueman
    state: present
  notify:
    - restart pulse as user

- name: Do not auto power on the bluetooth device
  lineinfile:
    dest: /etc/bluetooth/main.conf
    state: present
    line: "AutoEnable=false"

- name: Unblock the bluetooth service
  service:
    name: rfkill-block@bluetooth.service
    enabled: no
    state: stopped
  when: bluetooth.disable == False

- name: Enable and start the bluetooth service
  service:
    name: bluetooth.service
    enabled: yes
    state: started
  when: bluetooth.disable == False

- name: Disable and stop the bluetooth service
  service:
    name: bluetooth.service
    enabled: no
    state: stopped
  when: bluetooth.disable == True

- name: Block the bluetooth service
  service:
    name: rfkill-block@bluetooth.service
    enabled: yes
    state: started
  when: bluetooth.disable == True
