我在Ubuntu 20.10。它在2012年中期的macbook上运行。它运行的很好,但我仍然有一个小问题的权力管理。当我关上盖子时,macbook就挂起来了。但当我打开它,它就不会醒来。我知道可以将LID0和XHC1设置为/proc/acpi/wakeup。当你回音这些,然后它被切换。所以当我希望它启用时,我可能会关闭它。为此,我在askubuntu上找到了一个脚本,它适用于1台设备,而不是2台。但是脚本是为多个设备制作的。
这是原始脚本:
#!/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由用户制作或转发: Hrishikesh Kadam on:
在:"cat /proc/acpi/wakeup“中,这些是XHC1和LID0项目:
XHC1 S3 *disabled pci:0000:00:14.0
LID0 S4 *disabled platform:PNP0C0D:00我改变了我找到的脚本如下:
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发布于 2021-04-15 20:46:12
看起来我已经找到了解决方案,从行中移除引号:声明-a devices=("XHC1 LID0")
然后我的脚本看起来是这样的:
#!/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就这样起作用了。有那么简单吗?
https://askubuntu.com/questions/1331529
复制相似问题