-
-
Save satmandu/2f2da70a7a6bbbacdba01ef8fb8c18f4 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# ***Note*** You need machinectl installed. | |
# This can be found in the systemd-container package on Ubuntu! | |
# | |
# Place this nvidia-wallpaper-restore-on-resume.sh script in /lib/systemd/system-sleep/ | |
# Then run: sudo chmod +x /lib/systemd/system-sleep/nvidia-wallpaper-restore-on-resume.sh | |
# | |
# 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. | |
# Note that this is fixed in mutter version 3.33.4, which should be in stable mutter 3.34 builds. | |
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" ] || [ ${#pid_Gnome[@]} == 1 ]; then | |
log "machinectl shell $user@.host $command" | |
/bin/machinectl shell $user@.host $command | |
fi | |
done | |
fi | |
exit 0 |
Thanks @diegogiglio I updated the top of the script to make that more explicit!
Try it?
It won't harm your system.
And this is more of a workaround than a fix, for which you need to wait for the next version of mutter to go stable in Gnome.
"Place this nvidia-wallpaper-restore-on-resume.sh script in /lib/systemd/system-sleep/"
Can you tell me how I'm to copy this file inside systemd? Copy/Paste is not working. Any help appreciated :)
"Place this nvidia-wallpaper-restore-on-resume.sh script in /lib/systemd/system-sleep/"
Can you tell me how I'm to copy this file inside systemd? Copy/Paste is not working. Any help appreciated :)
Open a terminal app and paste in the following and hit enter, and type in your password when prompted since sudo needs it to elevate permissions for the install:
sudo bash <<"EOF"
wget https://gist.githubusercontent.com/satmandu/2f2da70a7a6bbbacdba01ef8fb8c18f4/raw/092d51c0ed4a662d343482ca727f56186dbebe40/nvidia-wallpaper-restore-on-resume.sh -O /lib/systemd/system-sleep/nvidia-wallpaper-restore-on-resume.sh
chmod +x /lib/systemd/system-sleep/nvidia-wallpaper-restore-on-resume.sh
EOF
Thanks a lot @satmandu. This worked for me :D
"Place this nvidia-wallpaper-restore-on-resume.sh script in /lib/systemd/system-sleep/"
Can you tell me how I'm to copy this file inside systemd? Copy/Paste is not working. Any help appreciated :)Open a terminal app and paste in the following and hit enter, and type in your password when prompted since sudo needs it to elevate permissions for the install:
sudo bash <<"EOF" wget https://gist.githubusercontent.com/satmandu/2f2da70a7a6bbbacdba01ef8fb8c18f4/raw/092d51c0ed4a662d343482ca727f56186dbebe40/nvidia-wallpaper-restore-on-resume.sh -O /lib/systemd/system-sleep/nvidia-wallpaper-restore-on-resume.sh chmod +x /lib/systemd/system-sleep/nvidia-wallpaper-restore-on-resume.sh EOF
Would you mind shedding some light on why copy/paste didn't work there? My guess is it's because of permission issues. Any other way to copy/paste code there?
Hey, I wanna undo this command as it's now taking too long to get back from the lock screen. Can you tell how to revert the changes made after executing the above code?
sudo rm /lib/systemd/system-sleep/nvidia-wallpaper-restore-on-resume.sh
Guess it fixed my problem. Thank you.