From 23de12f7e95f98980f528c986b2b745fad7d089f Mon Sep 17 00:00:00 2001 From: earnest ma Date: Sun, 30 Jan 2022 19:45:21 -0500 Subject: [PATCH] Disable USB Wake service task Closes #5 --- roles/common/files/disable_usb_wake.service | 12 ++++++++++++ roles/common/handlers/main.yml | 7 +++++++ roles/common/tasks/disable_usb_wake.yml | 9 +++++++++ roles/common/tasks/main.yml | 4 ++++ 4 files changed, 32 insertions(+) create mode 100644 roles/common/files/disable_usb_wake.service create mode 100644 roles/common/handlers/main.yml create mode 100644 roles/common/tasks/disable_usb_wake.yml 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