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.
First this is bug #1464917:
If you think this bug is affecting you please report it to the bug link above, thank you.
Update:
There has been a development as a work around to this bug. It seems to be related to the swap file usage/management. Adam (from the bug link above) points out that if you turn your swap off, wait for it to process, before you shutdown the hang never happens. When you are ready to shutdown your machine, open a terminal window and type;
sudo swapoff -a
Wait for the command to process and give your prompt back then you should be able to perform normal shutdown. This is working for many including me.
end update
If the shutdown or reboot has hanged with this message Reached target Shutdown
Try Sysrq
- Hold down the Alt and SysRq (Print Screen) keys.
- While holding those down, type the following keys in order, several
seconds apart: REISUB
- Computer should reboot.
You can also try the following after it hangs.
see if you can login tty1 and reboot
- Press
Ctrl+Alt+F1
or Ctrl+Alt+F2
or Ctrl+Alt+F3
...
- Write your username (lowercase, the name of the user folder in
/home) and hit Enter
- Write your password (nothing will appear) and hit Enter
If your password and username are correct, you are now logged in.
If that fails try Ctrl+Alt+Del
a couple times at that point in the tty1 screen
You might see a message that states the machine is going to reboot and then it should do just that after a minute or so.
Its better than a hard boot - until its fixed
In the bug notes it is reported that you can upgrade to Vivid-Proposed and it fixes the issue but some still see this after that upgrade. It might be worth a shot.
Btw the same bug affects me and I have not tried the upgrade yet but the steps I listed do work.
Best Answer
Right...
Well thanks to all support I found the solution in the end for lubuntu LXQt 18.10
Finally I got rid of my laptop shutting down instead of suspending after pushing the power button...
I realize a power button logically should switch off power, but since the last 15 of years or so, people are used to have their laptops suspending by pushing it.
For others that have the same annoying thing and getting no answer for this simple question try this:
open terminal and run this command:
and than install a text editor like gedit, and edit a file:
and paste these lines at the end of the file:
and use keys Ctrl+S to save it.
The power button should suspend your laptop now.