The fact that the log contained /etc/pm/sleep.d/reset_panel resume suspend: Cant connect to display:
indicates that no display is set, and you are trying to run a graphical program. When you're running pm-suspend
from your session, the correct display was set probably by LightDM or whatever your display manager is. When it gets run automatically on resume, I assume it's getting run as the root user and not attached to a display. So you need to set the display variable yourself, like so:
#!/bin/bash
case "$1" in
suspend|hibernate)
#do nothing
;;
resume|thaw)
export DISPLAY=:0
sleep 5 && lxpanelctl restart & #Delayed so the battery icon can finish wrecking shop.
;;
*)
exit 1
;;
esac
exit 0
The only draw back is that this won't work if you display isn't actually :0
That's the default, but it could change particularly in a multi-user setting.
You are using the default nouveau driver, for your nvidia graphics card. This is a reverse engineered driver and is known to cause trouble with power management.
From what I can tell from my experience suspend with nouveau is gambling, depends very much on the kernel version, graphics card etc.
The first thing I would try if I were you is installing the official nvidia driver: Note, though, it is proprietary, but I would try to see if it resolves your problem, because then we know pretty much for sure nouveau is the component to blame. (Looking at all the errors on your screen I am pretty sure though nouveau is the trouble maker.)
If you have concern because the proprietary driver is closed source, you can set up a second ubuntu install on an external hdd/usb and try it there.
To try the proprietary nvidia driver do the following:
sudo apt-get install nvidia-current-updates
and reboot your machine after the process finished.
Please report back if that changes something for you.
If not, my second try would be disconnecting all external hardware (usb devices like scanners, printers etc.), to make sure nothing external triggers a wakeup.
EDIT: Please also paste the output of
lspci
since the error message on your screen says "Device 0000:01:00.0 failed to suspend" and that command helps us to find what device exactly that is, but I suppose your graphics card.
Added by questioner:
For all who have similar Problem with a Nvidia Card in a laptop, If you have further trouble (eg. if your OpenGL Version is still low, or your laptop needs a lot of energy), check if your card uses OPTIMUS technology. This means that you have an additional graphics card, which is used for not graphical expensive Applications. In contrast this second card is optimized for low energy usage. You can search on the in the optimus scetion on the Nvidia Site for your card. If found your card there install also bumblebee
and bumblebee-nvidia
. After that, to run a Application with your powerful graphics card you have to run your Application via
$ optirun <path to app>
Best Answer
Copy your script to:
You will need to use
sudo
powers. After copying flag it as executable:Additionally change all occurrences of:
to:
The percent sign is unnecessary.
The existing date command is OK:
However it is formatted as number of seconds since January 1, 1970 which isn't the most readable date format.
case statement
The
case
statement can be changed: