To change close lid action in Ubuntu :
Open the /etc/systemd/logind.conf file in a text editor as root, for example,
sudo nano /etc/systemd/logind.conf
Change this line :
#HandleLidSwitch=ignore
To this line :
HandleLidSwitch=suspend
Make sure its commented out.
Alternately you can also add this line, but i prefer the first one :
HandleLidSwitchDocked=suspend
Then run :
sudo service systemd-logind restart
Or reboot.
To Troubleshoot the hibernate/suspend mode you should type following command in terminal :
dmesg|less
There is usually an entry what application caused the suspension to fail:
[32467.560058] Freezing of tasks failed after 20.01 seconds (1 tasks refusing to freeze, wq_busy=0):
[32467.560115] plasma-desktop D 0000000000000000 0 2065 1 0x00800004
Fix suspend on laptops
sudo apt-get install uswsusp
Now test suspend with :
sudo s2ram
If it doesn't work use :
sudo s2ram --force
Next edit this file :
sudo nano /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux
Change code to :
#!/bin/sh
/sbin/s2ram --force
Edit :
Another fix :
Put a script in ' /etc/pm/sleep.d/ ' , scripts there will be run at suspend and resume. The file name should start with an ordering number, 00-49 for user scripts (for more details, see man pm-suspend).
The script could look like this
#!/bin/sh
(killall -9 mount.nfs; exit 0)
If you're having problems, check /var/log/pm-suspend.log that will log the attempt to suspend and to run your script.
Ubuntu Suspend not working FIX
Step 1:
Open up a terminal and create a script file as follows:
sudo nano /etc/pm/sleep.d/20_custom-ehci_hcd
Step 2:
Copy the entire script below into the file you just created and save it:
#!/bin/sh
VERSION=1.1
DEV_LIST=/tmp/usb-dev-list
DRIVERS_DIR=/sys/bus/pci/drivers
DRIVERS="ehci xhci" # ehci_hcd, xhci_hcd
HEX="[[:xdigit:]]"
MAX_BIND_ATTEMPTS=2
BIND_WAIT=0.1
unbindDev() {
echo -n > $DEV_LIST 2>/dev/null
for driver in $DRIVERS; do
DDIR=$DRIVERS_DIR/${driver}_hcd
for dev in `ls $DDIR 2>/dev/null | egrep "^$HEX+:$HEX+:$HEX"`; do
echo -n "$dev" > $DDIR/unbind
echo "$driver $dev" >> $DEV_LIST
done
#for bus in $EHCI_BUSES; do
echo -n $bus > /sys/bus/pci/drivers/ehci_hcd/unbind
# done
done
}
bindDev() {
if [ -s $DEV_LIST ]; then
while read driver dev; do
DDIR=$DRIVERS_DIR/${driver}_hcd
#for bus in $EHCI_BUSES; do
echo -n $bus > /sys/bus/pci/drivers/ehci_hcd/bind
#done
while [ $((MAX_BIND_ATTEMPTS)) -gt 0 ]; do
echo -n "$dev" > $DDIR/bind
if [ ! -L "$DDIR/$dev" ]; then
sleep $BIND_WAIT
else
break
fi
MAX_BIND_ATTEMPTS=$((MAX_BIND_ATTEMPTS-1))
done
done < $DEV_LIST
fi
rm $DEV_LIST 2>/dev/null
chvt 1
chvt 7
}
EHCI_BUSES="0000:00:1a.0 0000:00:1d.0"
case "$1" in
hibernate|suspend)
unbindDev;;
resume|thaw)
bindDev;;
esac
Step 3:
Give the script run permissions by typing:
sudo chmod 755 /etc/pm/sleep.d/20_custom-ehci_hcd