In Fedora 28 on my Dell Precision laptop, when I close the lid, the suspension starts, but the laptop wakes up almost immediately, so I cannot suspend properly.
The problem is that BlueTooth is causing the laptop to ignore the suspend signal. This is easily fixed with the following workaround.
- Turn on bluetooth and type ‘lsusb’. In my case I see this
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 8087:0a2b Intel Corp.
Bus 001 Device 004: ID 0bda:5650 Realtek Semiconductor Corp.
Bus 001 Device 003: ID 0a5c:5834 Broadcom Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Now turn off Bluetooth and again type ‘lsusb’. Now I see this
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 0bda:5650 Realtek Semiconductor Corp.
Bus 001 Device 003: ID 0a5c:5834 Broadcom Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
So from this, I know that the USB device is vendor 8087 and product 0a2b. I need these values for the next step.
Now create a file called /usr/local/bin/bluetooth-sleep and in it, paste this :-
!/bin/bash
Disable bluetooth given first argument “start”
Re-enable bluetooth given first argument “stop”
Expects vendor and product as sedond and 3rd arguments
set -eu
usage() {
script_name=”/usr/local/bin/bluetooth-sleep”
printf ‘%s: de-authorise bluetooth during sleep/suspend\n’ “$script_name” >&2
printf ‘Usage: %s (start|stop) \n’ “$script_name” >&2
exit 1
}
case “${1:-}” in
start) value=0 ;;
stop) value=1 ;;
*) usage ;;
esac
[ $# -ne 3 ] && usage
vendor=$2
product=$3
shopt -s nullglob
for dir in /sys/bus/usb/devices/*; do
if [[ -L “$dir” && -f $dir/idVendor && -f $dir/idProduct &&
$(cat “$dir/idVendor”) == “$vendor” &&
$(cat “$dir/idProduct”) == “$product” ]] ; then
echo “$value” > “$dir/authorized”
echo “echo $value > $dir/authorized”
fi
done
Next, create a file called /etc/systemd/system/bluetooth-disable-before-sleep.service
In it, paste this :-
[Unit]
Description=disable bluetooth for system sleep/suspend targets
Before=sleep.target
Before=suspend.target
Before=hybrid-sleep.target
Before=suspend-then-hybernate.target
StopWhenUnneeded=yes
[Service]
Type=oneshot
RemainAfterExit=yes
Usage: blootooth-sleep (start|stop)
Get values from lsusb
eq: Bus 001 Device 003: ID 8087 0a2b Intel Corp
Usage: bluetooth-sleep (start|stop) 8087 0a2b
ExecStart=/usr/local/bin/bluetooth-sleep start 8087 0a2b
ExecStop= /usr/local/bin/bluetooth-sleep stop 8087 0a2b
[Install]
WantedBy=sleep.target
WantedBy=suspend.target
WantedBy=hybrid-sleep.target
WantedBy=suspend-then-hibernate.target
Note that the values used in this second file include 8087 and 0a2b which relate to the bluetooth device connected to the internal usb hub (it is not a plugin usb device).
The final step is to enable the new service
systemctl enable bluetooth-disable-before-sleep.service
You should be able to turn off bluetooth by running :-
/usr/local/bin/bluetooth-sleep start 8087 0a2b
and turn it on again by running :-
/usr/local/bin/bluetooth-sleep stop 8087 0a2b
And now that you have started the systemctl process, closing your laptop lid should first turn off bluetooth and then suspend. The suspend should now work. And when you open the laptop, the bluetooth should restart.
I hope it works for you.