diff --git a/roles/common/files/disable_usb_wake.service b/roles/common/files/disable_usb_wake.service new file mode 100644 index 0000000..85e74fd --- /dev/null +++ b/roles/common/files/disable_usb_wake.service @@ -0,0 +1,12 @@ +[Unit] +Description=Disable USB Mouse from waking +After=getty.target + +[Service] +Type=oneshot +User=root +ExecStart=/usr/bin/bash -c "for i in $(cat /proc/acpi/wakeup| grep enabled | awk '{print $1}'| xargs); do echo $i | tee /proc/acpi/wakeup; done" +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/roles/common/handlers/main.yml b/roles/common/handlers/main.yml new file mode 100644 index 0000000..fa4cb7e --- /dev/null +++ b/roles/common/handlers/main.yml @@ -0,0 +1,7 @@ +--- +- name: ensure_systemd_file_is_enabled + ansible.builtin.systemd: + name: disable_usb_wake.service + daemon_reload: yes + enabled: yes + state: restarted diff --git a/roles/common/tasks/disable_usb_wake.yml b/roles/common/tasks/disable_usb_wake.yml new file mode 100644 index 0000000..1157131 --- /dev/null +++ b/roles/common/tasks/disable_usb_wake.yml @@ -0,0 +1,9 @@ +--- +- name: Copy disable usb wake service file + copy: + src: disable_usb_wake.service + dest: /etc/systemd/system/disable_usb_wake.service + owner: root + group: root + mode: 0644 + notify: ensure_systemd_file_is_enabled diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 3dfce46..e41a506 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -8,3 +8,7 @@ - include: packages.yml - include: users.yml - include: nix.yml + +- name: Disable wake on USB + import_tasks: disable_usb_wake.yml + when: disable_usb_wake == True