If you use an Nvidia driver with a Gnome desktop and you decide to resume your system from a suspension or hibernation, you will see that your desktop it's broken like in this screenshot.
To fix this problem we need to refresh the Gnome desktop after this happens. We have created a bash script that refresh Gnome desktop after resuming the system. Follow the steps below to implement it in your system:
You can use the text editor that you prefer, we will use nano.
sudo nano /lib/systemd/system-sleep/broken-desktop-fix |
2. Now you can copy and paste in this new file the follow bash script that we mentioned. This script will refresh Gnome desktop each time you resume after suspension/hibernation.
#!/bin/bash case "$1" in post) DISPLAY=:0.0 ; export DISPLAY STR="$(users)" echo ${STR} IFS=' ' read -ra NAMES <<< ${STR} for i in "${NAMES[@]}"; do su $i -c 'dbus-send --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval "string:global.reexec_self()"' done;; esac |
- After saving the file you will need assign file permissions.
sudo chmod 755 /lib/systemd/system-sleep/broken-desktop-fix |
Also we can do it manually each time it happens with Alt + F2 and then in the text box introduce r and finally press Enter, and Gnome will refresh to fix it.