X11 on bookworm
X11 wants to blank the screen out of the box. To prevent, try putting
xset dpms 0 0 0 && xset s noblank && xset s off
in .bashrc
Systemd timeouts
For systems which should never attempt any type of suspension, these targets can be disabled at the systemd level with the following:
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
To re-enable hibernate and suspend use the following command:
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
A modern alternative approach for disabling suspend and hibernation is to create /etc/systemd/sleep.conf.d/nosuspend.conf as
[Sleep] AllowSuspend=no AllowHibernation=no AllowSuspendThenHibernate=no AllowHybridSleep=no
The above technique works on Debian 10 Buster and newer. See systemd-sleep.conf(5) for details.
If you just want to prevent suspending when the lid is closed you can set the following options in /etc/systemd/logind.conf:
[Login] HandleLidSwitch=ignore HandleLidSwitchDocked=ignore
Then run systemctl restart systemd-logind.service or reboot.
More information is available in the manpage: man logind.conf