Cobra Forum

Linux Specialised Support => Apple Hardware Users => Topic started by: kalpana on Oct 26, 2023, 03:47 AM

Title: acpi wake up script fix
Post by: kalpana on Oct 26, 2023, 03:47 AM
I've Ubuntu 20.10 running on a laptop.
It is running very well, but I still have a small issue with power management. When I close the lid, the laptop suspends. But when I open it, it does not wake up.
I want to echo LID0 and XHC1 to /proc/acpi/wakeup when one or both of them are disabled.

I've found a script, that was working wel for others. This is the original script:
Code:
#!/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

In: "cat /proc/acpi/wakeup" these are the XHC1 and LID0 items:
Code:
XHC1      S3    *disabled   pci:0000:00:14.0
LID0      S4    *disabled  platform:PNP0C0D:00

I changed the script like this:
Code:
#!/bin/bash
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

But than I get this error:
Code:
grep: LID0.*disabled: File or folder does not exist
When I change the code like this:
Code:
declare -a devices=("XHC1")

so by removing 1 device, then the code works.

Can someone help me solve this script problem?