diff options
Diffstat (limited to 'roles/logind')
| -rw-r--r-- | roles/logind/defaults/main.yml | 5 | ||||
| -rw-r--r-- | roles/logind/handlers/main.yml | 6 | ||||
| -rw-r--r-- | roles/logind/meta/argument_specs.yml | 44 | ||||
| -rw-r--r-- | roles/logind/meta/main.yml | 18 | ||||
| -rw-r--r-- | roles/logind/tasks/main.yml | 17 | ||||
| -rw-r--r-- | roles/logind/templates/logind.conf.j2 | 5 |
6 files changed, 95 insertions, 0 deletions
diff --git a/roles/logind/defaults/main.yml b/roles/logind/defaults/main.yml new file mode 100644 index 00000000..bff32a33 --- /dev/null +++ b/roles/logind/defaults/main.yml @@ -0,0 +1,5 @@ +--- +logind_lid_ac_action: "suspend" +logind_lid_battery_action: "suspend" +logind_idle_action: "suspend" +logind_idle_delay: 0 diff --git a/roles/logind/handlers/main.yml b/roles/logind/handlers/main.yml new file mode 100644 index 00000000..617bb197 --- /dev/null +++ b/roles/logind/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: "Reload systemd-logind" + become: true + ansible.builtin.systemd_service: + name: "systemd-logind" + state: "restarted" diff --git a/roles/logind/meta/argument_specs.yml b/roles/logind/meta/argument_specs.yml new file mode 100644 index 00000000..4dca7643 --- /dev/null +++ b/roles/logind/meta/argument_specs.yml @@ -0,0 +1,44 @@ +--- +argument_specs: + main: + options: + logind_lid_battery_action: + type: "str" + description: "HandleLidSwitch — action when lid closed on battery" + default: "suspend" + choices: + - "ignore" + - "suspend" + - "hibernate" + - "hybrid-sleep" + - "suspend-then-hibernate" + - "lock" + - "poweroff" + logind_lid_ac_action: + type: "str" + description: "HandleLidSwitchExternalPower — action when lid closed on AC power" + default: "suspend" + choices: + - "ignore" + - "suspend" + - "hibernate" + - "hybrid-sleep" + - "suspend-then-hibernate" + - "lock" + - "poweroff" + logind_idle_action: + type: "str" + description: "IdleAction — action after idle timeout" + default: "suspend" + choices: + - "ignore" + - "suspend" + - "hibernate" + - "hybrid-sleep" + - "suspend-then-hibernate" + - "lock" + - "poweroff" + logind_idle_delay: + type: "int" + description: "IdleActionSec in seconds (0 disables idle action)" + default: 0 diff --git a/roles/logind/meta/main.yml b/roles/logind/meta/main.yml new file mode 100644 index 00000000..7ab91f4a --- /dev/null +++ b/roles/logind/meta/main.yml @@ -0,0 +1,18 @@ +--- +dependencies: + - role: "systemd" +galaxy_info: + author: "a14m" + description: "Configure systemd-logind lid switch and idle behavior" + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "ArchLinux" + versions: + - "all" + - name: "Ubuntu" + versions: + - "noble" + - name: "Debian" + versions: + - "bookworm" diff --git a/roles/logind/tasks/main.yml b/roles/logind/tasks/main.yml new file mode 100644 index 00000000..3b5aad5c --- /dev/null +++ b/roles/logind/tasks/main.yml @@ -0,0 +1,17 @@ +--- +- name: "Ensure /etc/systemd/logind.conf.d exists" + become: true + ansible.builtin.file: + path: "/etc/systemd/logind.conf.d" + state: "directory" + mode: "0755" + +- name: "Configure systemd-logind" + become: true + ansible.builtin.template: + src: "logind.conf.j2" + dest: "/etc/systemd/logind.conf.d/override.conf" + owner: "root" + group: "root" + mode: "0644" + notify: "Reload systemd-logind" diff --git a/roles/logind/templates/logind.conf.j2 b/roles/logind/templates/logind.conf.j2 new file mode 100644 index 00000000..b1269b15 --- /dev/null +++ b/roles/logind/templates/logind.conf.j2 @@ -0,0 +1,5 @@ +[Login] +HandleLidSwitch={{ logind_lid_battery_action }} +HandleLidSwitchExternalPower={{ logind_lid_ac_action }} +IdleAction={{ logind_idle_action }} +IdleActionSec={{ logind_idle_delay }} |
