0

I'm on Ubuntu 20.10. It runs on a macbook pro mid 2012. It is running very well, but I still have a small issue with power management. When I close the lid, the macbook suspends. But when I open it, it does not wake up. I do know that I can set LID0 and XHC1 with an echo to /proc/acpi/wakeup. When you echo these, then it is switched. So possibly I switch it off while I want it to have enabled. Therefor I've found a script on askubuntu, that works well with 1 device, but not with 2. But the script was made for more then one device.

This is the original script:

#!/bin/bash
declare -a devices=("EHC1 EHC2 XHCI") # <-- Add your entries here
for device in "${devices[@]}"; do
    if grep -qw ^$device.*enabled /proc/acpi/wakeup; then
        sudo sh -c "echo $device > /proc/acpi/wakeup"
    fi
done

Made, or reposted by a user: Hrishikesh Kadam on: [AskUbuntu][1].

In: "cat /proc/acpi/wakeup" these are the XHC1 and LID0 items:

XHC1      S3    *disabled   pci:0000:00:14.0 
LID0      S4    *disabled  platform:PNP0C0D:00

I changed the script that I've found like this:

declare -a devices=("XHC1 LID0")
for device in "${devices[@]}"; do
    if grep -qw ^$device.*disabled /proc/acpi/wakeup; then
        sudo sh -c "echo $device > /proc/acpi/wakeup"
    fi
done ```

Which does not look wrong to me. But than I get this error: 

    grep: LID0.*disabled: File or folder does not exist

When I change the code like this: 

    declare -a devices=("XHC1")
so by removing 1 device, then the code works.

Why does this not work anymore? What changed in the way this is working? And how do I fix this script for Ubuntu 20.10? Please advise.
Anyone? 


  [1]: https://askubuntu.com/questions/1146264/apply-the-proc-acpi-wakeup-settings-permanently/1331422#1331422

1 Answer 1

0

It looks like I've found the solution by removing the quotes from the line: declare -a devices=("XHC1 LID0")

Then my script looks like this:

#!/bin/bash
declare -a devices=( LID0 XHC1 )
for device in "${devices[@]}"; do
    if grep -qw ^$device.*disabled /proc/acpi/wakeup; then
        sudo sh -c "echo $device > /proc/acpi/wakeup"
    fi
done

In this way it is working. Is it that easy?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.