/ linux

How To Stop Fedora Waking Up A Closed MacBook Pro

My late 2013 MacBook Pro is on its last legs and I'm, struggling to justify spending over two grand on a replacement as I just don't like the new keyboards and I don't think they're good value for money. To that end, I'm currently looking to see if I can tolerate Linux as a replacement for macOS by dual booting on my MacBook Pro. If I can get on with it then I'll buy a new (much cheaper) laptop to run it - maybe the new Dell XPS or ThinkPad.

Anyway, I'm using Fedora 26 and mostly it works well. The only major issue I had was that if I put the MBP to sleep by closing its lid, it would randomly turn back on again after a few seconds. If this happened in my backpack then I ended up with a very warm laptop with a very dead battery. It turns out that it's due to the USB 3.0 bus waking the laptop up sporadically. To disable this "feature" you need execute sudo echo XHC1 > /proc/acpi/wakeup. This will disable USB wakeup but only for the current session. To make it permanent, I created a systemd service that runs at startup. First create the following file:

sudo nano /etc/systemd/system/fixwakeup.service

and put the following in it:

[Unit]
Description=Stops the USB bus waking the Mac up 

[Service]
ExecStart=/bin/bash -c "echo XHC1 >> /proc/acpi/wakeup"

[Install]
WantedBy=multi-user.target

To make it run at boot type: sudo systemctl enable something

Reboot and you should be good to go.