Sleep-then-hibernate (Debian Sid, Framework Laptop, Window Maker)

  ___   _                            _     _                         _      _   _                                _         
 / __| | |  ___   ___   _ __   ___  | |_  | |_    ___   _ _    ___  | |_   (_) | |__   ___   _ _   _ _    __ _  | |_   ___ 
 \__ \ | | / -_) / -_) | '_ \ |___| |  _| | ' \  / -_) | ' \  |___| | ' \  | | | '_ \ / -_) | '_| | ' \  / _` | |  _| / -_)
 |___/ |_| \___| \___| | .__/        \__| |_||_| \___| |_||_|       |_||_| |_| |_.__/ \___| |_|   |_||_| \__,_|  \__| \___|
                       |_|                                                                                                 

   __  ___          _      _               
  / / |   \   ___  | |__  (_)  __ _   _ _  
 | |  | |) | / -_) | '_ \ | | / _` | | ' \ 
 | |  |___/  \___| |_.__/ |_| \__,_| |_||_|
  \_\                                      

  ___   _      _     
 / __| (_)  __| |    
 \__ \ | | / _` |  _ 
 |___/ |_| \__,_| ( )
                  |/ 

  ___                                                   _   
 | __|  _ _   __ _   _ __    ___  __ __ __  ___   _ _  | |__
 | _|  | '_| / _` | | '  \  / -_) \ V  V / / _ \ | '_| | / /
 |_|   |_|   \__,_| |_|_|_| \___|  \_/\_/  \___/ |_|   |_\_\
                                                            

  _                    _                    
 | |     __ _   _ __  | |_   ___   _ __     
 | |__  / _` | | '_ \ |  _| / _ \ | '_ \  _ 
 |____| \__,_| | .__/  \__| \___/ | .__/ ( )
               |_|                |_|    |/ 

 __      __  _             _                
 \ \    / / (_)  _ _    __| |  ___  __ __ __
  \ \/\/ /  | | | ' \  / _` | / _ \ \ V  V /
   \_/\_/   |_| |_||_| \__,_| \___/  \_/\_/ 
                                            

  __  __          _                __  
 |  \/  |  __ _  | |__  ___   _ _  \ \ 
 | |\/| | / _` | | / / / -_) | '_|  | |
 |_|  |_| \__,_| |_\_\ \___| |_|    | |
                                   /_/ 

╔─*──*──*──*──*──*──*──*──*──*──*──*──*──*──*──*─╗
║1   ........................................   1║
║2*  ........................................  *2║
║3   ........................................   3║
║1   ...........Posted: 2026-03-13...........   1║
║2*  ..Tags: windowmaker debian framework ...  *2║
║3   ........................................   3║
║1   ........................................   1║
╚────────────────────────────────────────────────╝

How to sleep then hibernate...

I learned this setup because I wanted Window Maker-compatible power management.

### Suspend-Then-Hibernate on Debian Sid (Framework AMD)

*Terse phlog note*

#### Goal

Fix overnight battery drain from `s2idle` by enabling **lid → suspend →
hibernate**.

#### What I changed

1. **Create large swapfile (hibernate image storage)**

```
fallocate -l 64G /swapfile-hibernate
chmod 600 /swapfile-hibernate
mkswap /swapfile-hibernate
swapon /swapfile-hibernate
```

Add to `/etc/fstab`:

```
/swapfile-hibernate none swap defaults 0 0
```

2. **Configure resume from swapfile**

Find offset:

```
filefrag -v /swapfile-hibernate | grep " 0:"
```

Add to `/etc/default/grub`:

```
resume=/dev/mapper/framework--vg-root resume_offset=<OFFSET>
```

Honestly my full grub line looks like:

```
GRUB_CMDLINE_LINUX_DEFAULT="quiet mem_sleep_default=deep xe.force_probe=9a49 i915.force_probe=!9a49 resume=/dev/mapper/framework--vg-root resume_offset=68972544"
```

Then:

```
update-grub
reboot
```

3. **Enable suspend-then-hibernate**

`/etc/systemd/sleep.conf`

```
[Sleep]
AllowSuspendThenHibernate=yes
HibernateDelaySec=20min
HibernateOnACPower=no
```

4. **Ensure lid action uses suspend-then-hibernate**

`/etc/systemd/logind.conf.d/lid.conf`

```
[Login]
HandleLidSwitch=suspend-then-hibernate
HandleLidSwitchExternalPower=suspend
LidSwitchIgnoreInhibited=yes
```

Reload:

```
systemctl daemon-reexec
systemctl restart systemd-logind
```

Result:

```
lid close
→ suspend (s2idle)
→ 20 min
→ hibernate
→ power off
```

------------------------------
## Caveats encountered

### Hidden logind override

`/etc/systemd/logind.conf.d/lid.conf` was forcing:

```
HandleLidSwitch=suspend
```

This silently overrides `/etc/systemd/logind.conf`.

Check effective config:

```
systemd-analyze cat-config systemd/logind.conf
```

------------------------------
### Swap too small

Hibernate fails with:

```
Not enough suitable swap space
```

Fix: swap ≥ RAM (or close).

------------------------------
### Swapfile requires resume_offset

Without offset kernel cannot find hibernate image.

```
filefrag -v /swapfile-hibernate
```

------------------------------
### sleep.conf defaults are commented

Lines beginning with `#` are ignored.

Example mistake:

```
#AllowSuspendThenHibernate=yes
```

Must remove `#`.

------------------------------
### AC power prevents hibernate unless allowed

Need:

```
HibernateOnACPower=yes
```

------------------------------
## Debugging

### Verify lid events

```
acpi_listen
```

Expected:

```
button/lid LID close
```

------------------------------
### Watch sleep pipeline

```
journalctl -f \
-u systemd-logind \
-u systemd-suspend.service \
-u systemd-suspend-then-hibernate.service \
-u systemd-hibernate.service
```

Expected sequence:

```
Starting systemd-suspend-then-hibernate.service
Performing sleep operation 'suspend'
Performing sleep operation 'hibernate'
```

------------------------------
### Confirm hibernate resume

```
journalctl -b | grep -i hibern
```

Look for:

```
System returned from sleep operation 'hibernate'
PM: hibernation exit
```

------------------------------
### Detect override configs

```
systemd-analyze cat-config systemd/logind.conf
systemd-analyze cat-config systemd/sleep.conf
```

------------------------------
### Check suspend mode

```
cat /sys/power/mem_sleep
```

Framework AMD typically shows:

```
s2idle
```

------------------------------
### Manual test

```
systemctl hibernate
```

Should power off then restore session.

------------------------------
**Net result:** reliable laptop sleep with zero overnight battery drain.