Trying to fix resume problems on Ubuntu 22.04 with Nvidia

Thu Feb 09 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

A certain error message: "Freezing of tasks failed after 20.009 seconds", led me to this discussion on Nvidia.

https://forums.developer.nvidia.com/t/trouble-suspending-with-510-39-01-linux-5-16-0-freezing-of-tasks-failed-after-20-009-seconds/200933/12

Now installed it, will have to wait and see if it works.

As described in the comment, more or less:

sudo nano -w /usr/local/bin/suspend-gnome-shell.sh

And put in:

#!/bin/bash

case "$1" in
    suspend)
        killall -STOP gnome-shell
        ;;
    resume)
        killall -CONT gnome-shell
        ;;
esac

sudo nano -w /etc/systemd/system/gnome-shell-suspend.service

and put in:

[Unit]
Description=Suspend gnome-shell
Before=systemd-suspend.service
Before=systemd-hibernate.service
Before=nvidia-suspend.service
Before=nvidia-hibernate.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/suspend-gnome-shell.sh suspend

[Install]
WantedBy=systemd-suspend.service
WantedBy=systemd-hibernate.service

sudo nano -w /etc/systemd/system/gnome-shell-resume.service

and put in:

[Unit]
Description=Resume gnome-shell
After=systemd-suspend.service
After=systemd-hibernate.service
After=nvidia-resume.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/suspend-gnome-shell.sh resume

[Install]
WantedBy=systemd-suspend.service
WantedBy=systemd-hibernate.service

Enable the two new systemd units:

sudo systemctl daemon-reload
sudo systemctl enable gnome-shell-suspend
sudo systemctl enable gnome-shell-resume