diff --git a/roles/pc-lid-switch/handlers/main.yml b/roles/pc-lid-switch/handlers/main.yml new file mode 100644 index 00000000..bd9cae9a --- /dev/null +++ b/roles/pc-lid-switch/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: Restart systemd-logind + become: yes + systemd: + name: systemd-logind + state: restarted \ No newline at end of file diff --git a/roles/pc-lid-switch/tasks/main.yml b/roles/pc-lid-switch/tasks/main.yml new file mode 100644 index 00000000..3f977c32 --- /dev/null +++ b/roles/pc-lid-switch/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Set HandleLidSwitch to hibernate in /etc/systemd/logind.conf + become: yes + lineinfile: + path: /etc/systemd/logind.conf + regexp: '^#?HandleLidSwitch=' + line: 'HandleLidSwitch=hibernate' + backup: yes + notify: Restart systemd-logind \ No newline at end of file