---
- name: π¦ Install setup-hibernate via pip (system-wide)
include_role:
name: sys-pip-install
vars:
package_name: setup-hibernate
global_install: true
- name: π§ Setup hibernate
ansible.builtin.command:
argv:
- "{{ lookup('command_path', 'setup-hibernate') }}"
- --non-interactive
become: true
- name: "π§ Lid switch: hibernate on battery, lock on AC/docked"
become: true
lineinfile:
path: /etc/systemd/logind.conf
regexp: "^#?HandleLidSwitch="
line: "HandleLidSwitch=hibernate"
backup: true
notify: restart-systemd-logind
- name: π§ Configure systemd to lock session when lid is closed on external power
lineinfile:
path: /etc/systemd/logind.conf
regexp: "^#?HandleLidSwitchExternalPower="
line: "HandleLidSwitchExternalPower=lock"
backup: true
notify: restart-systemd-logind
become: true
- name: π§ Configure systemd to lock session when lid is closed while docked
lineinfile:
path: /etc/systemd/logind.conf
regexp: "^#?HandleLidSwitchDocked="
line: "HandleLidSwitchDocked=lock"
backup: true
notify: restart-systemd-logind
become: true
- include_tasks: utils/once/flag.yml