由于某种原因,我的机器在暂停时出现问题,具体来说,它一暂停就会恢复。经过一番研究,我能够通过使用以下循环在 14.04 上解决此问题,如以下答案所示:https://askubuntu.com/a/268172
#!/bin/bash
case $1 in
hibernate)
echo "Going to suspend to disk!"
;;
suspend)
echo "Fixing acpi settings."
for usb in 'XHC' 'EHC1' 'EHC2';
do
state=`cat /proc/acpi/wakeup | grep $usb | cut -f3 | cut -d' ' -f1 | tr -d '*'`
echo "device = $usb, state = $state"
if [ "$state" == "enabled" ]
then
echo $usb > /proc/acpi/wakeup
fi
done
echo "Suspending to RAM."
;;
thaw)
echo "Suspend to disk is now over!"
;;
resume)
echo "We are now resuming."
;;
*)
echo "Somebody is callin me totally wrong."
;;
esac
但是,使用新的 systemd 时,这个解决方案不再起作用,我设法在 /usr/lib/systemd/system-sleep/ 上创建并放置相同的脚本,但是这不起作用,因为它没有执行,这是我的日志的输出:
may 22 22:59:43 waiobook systemd[1]: Starting Suspend...
may 22 22:59:43 waiobook systemd-sleep[1372]: Suspending system...
may 22 22:59:49 waiobook systemd-sleep[1372]: System resumed.
may 22 22:59:49 waiobook systemd[1]: Started Suspend.
may 22 20:09:03 waiobook systemd[1]: Starting Suspend...
may 22 20:09:03 waiobook systemd-sleep[2674]: Suspending system...
may 22 20:09:07 waiobook systemd-sleep[2674]: System resumed.
may 22 20:09:07 waiobook systemd[1]: Started Suspend.
所以我猜我的脚本有问题?
任何帮助都将不胜感激。
答案1
脚本参数和目录都已更改。$1
在 resume/thaw 上为“post”,否则为“pre”。$2
在两种情况下都包含“suspend”、“hibernate”或“hybrid-sleep”。修改您的示例:
#!/bin/bash
case $1 in
pre) case $2 in
hibernate)
echo "Going to suspend to disk!"
;;
hybrid-sleep)
echo "Going to suspend to disk and ram!"
;;
suspend)
echo "Fixing acpi settings."
for usb in 'XHC' 'EHC1' 'EHC2';
do
state=`cat /proc/acpi/wakeup | grep $usb | cut -f3 | cut -d' ' -f1 | tr -d '*'`
echo "device = $usb, state = $state"
if [ "$state" == "enabled" ]
then
echo $usb > /proc/acpi/wakeup
fi
done
echo "Suspending to RAM."
;;
*)
echo "Somebody is callin me totally wrong."
;;
esac ;;
post)
echo "We are now resuming from $2."
;;
*)
echo "Somebody is callin me totally wrong."
;;
esac