Comment 41 for bug 1809407

Revision history for this message
satmandu (satadru-umich) wrote :

I fixed the workaround script mentioned above here:

https://gist.github.com/satmandu/2f2da70a7a6bbbacdba01ef8fb8c18f4

This "works" on my system.

(dbus-send doesn't get the right info to work unless you give it the info of the logged in user, which "machinectl shell" can do.)

Hopefully the fix gets merged soon and I can stop using this ugly hack. :)

#!/bin/bash
# Place file in /lib/systemd/system-sleep/
# Run chmod +x on the file.
# This works around the wallpaper corruption on resume from suspend with Nvidia GPUs
# reported at https://gitlab.gnome.org/GNOME/gnome-shell/issues/1084
# and due to this feature of the Nvidia driver:
# https://www.khronos.org/registry/OpenGL/extensions/NV/NV_robustness_video_memory_purge.txt
# Adapted from Paul Knopf (https://gitlab.gnome.org/GNOME/gnome-shell/issues/1084)
# and via https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/1809407/comments/22
# Note that this does show the user's screen when coming out of sleep briefly.
# machinectl can be found in the systemd-container package on Ubuntu.

PROGNAME=$(/usr/bin/basename "$0")
state=$1
action=$2

function log {
    /usr/bin/logger -i -t "$PROGNAME" "$*"
}

log "Running $action $state"
if [[ $state == post ]]; then
    log "WAKE UP"
    pid_Gnome=($(/usr/bin/pgrep gnome-session))
    pid_Gnome=("${pid_Gnome[@]%%:*}")
    command="/usr/bin/dbus-send --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval "string:global.reexec_self\(\)""
        for i in "${pid_Gnome[@]}"
    do
        user=$(/bin/ps -o user= -p $i)
        log $i $user
        if [ "$user" != "gdm" ]; then
            log "machinectl shell $user@.host $command"
            /bin/machinectl shell $user@.host $command
        fi
    done
fi
exit 0