Correctly configure sleep and hibernation

This commit is contained in:
Oliver Traber 2025-08-06 10:40:02 +02:00
parent cfd2b9be69
commit 142ccb8815
Signed by: Bluemedia
GPG key ID: C0674B105057136C
4 changed files with 22 additions and 1 deletions

View file

@ -0,0 +1,2 @@
[Login]
HandleLidSwitch=suspend-then-hibernate

View file

@ -0,0 +1,2 @@
[Sleep]
HibernateDelaySec=15min

View file

@ -23,6 +23,18 @@
- "/usr/bin/systemctl reboot" - "/usr/bin/systemctl reboot"
- "/usr/bin/systemctl suspend" - "/usr/bin/systemctl suspend"
- name: Copy sleep and hibernation config drop-ins for systemd on mobile platforms
become: yes
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
loop:
- src: "{{ role_path }}/files/systemd/logind.conf.d"
dest: "/etc/systemd/"
- src: "{{ role_path }}/files/systemd/sleep.conf.d"
dest: "/etc/systemd/"
when: hostvars[ansible_hostname]['mobile_platform']
- name: Copy static config files - name: Copy static config files
copy: copy:
src: "{{ item.src }}" src: "{{ item.src }}"
@ -34,6 +46,10 @@
dest: "{{ ansible_env.HOME }}/" dest: "{{ ansible_env.HOME }}/"
- src: "{{ role_path }}/files/.zshrc" - src: "{{ role_path }}/files/.zshrc"
dest: "{{ ansible_env.HOME }}/" dest: "{{ ansible_env.HOME }}/"
- src: "{{ role_path }}/files/systemd/logind.conf.d"
dest: "/etc/systemd/"
- src: "{{ role_path }}/files/systemd/sleep.conf.d"
dest: "/etc/systemd/"
- name: Ensure presence of required directories - name: Ensure presence of required directories
file: file:

View file

@ -14,7 +14,8 @@ idle() {
swayidle -w \ swayidle -w \
timeout 180 '~/.local/bin/hyprhelpr lock' \ timeout 180 '~/.local/bin/hyprhelpr lock' \
timeout 240 'hyprctl dispatch dpms off' \ timeout 240 'hyprctl dispatch dpms off' \
resume 'hyprctl dispatch dpms on' resume 'hyprctl dispatch dpms on' \
before-sleep '~/.local/bin/hyprhelpr lock'
} }
lock() { lock() {