sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
This does not seem to work in Debian 12. System still throws notifications and still goes into sleep mode. Per the Debian wiki, now, you need to create a file at /etc/systemd/sleep.conf.d/disable-suspend-hibernate.conf, although the name of the file is not important, the location of the file is .etc.systemd/sleep.conf.d directory. And set the content to:
[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.