00_core.ymlΒΆ

---
- 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