为什么我的笔记本电脑会挂起两次/三次?

为什么我的笔记本电脑会挂起两次/三次?

WMawesome在合上盖子时不会自动暂停,所以我遵循了一些指示让它发挥作用。我只是添加了一个/etc/acpi/local/lid.sh.post包含以下内容的文件:

#!/bin/sh
pm-suspend

暂停现在可以工作,但在我打开盖子并按下电源按钮后,它会显示桌面几分之一秒,然后再次暂停!第二次按电源按钮时,它会正常恢复。之后,每当我暂停时,我都必须按下电源按钮并等待数次后才能正常恢复。我已经尝试连续暂停四次,而且情况似乎并没有变得更糟。

编辑: 我用的是简单的屏幕锁定服务而不是原来的脚本:

[Unit]
Description=Lock X session
Before=sleep.target

[Service]
Environment=DISPLAY=:0
ExecStart=/usr/bin/xautolock -locknow

[Install]
WantedBy=sleep.target

但这并不是一个完美的解决方案。

解决了!如果其他人想要的话,我做了一个脚本用一个命令执行此操作:

#!/usr/bin/env bash
#
# NAME
#        suspend-on-close.sh - Enable suspend when closing laptop lid
#
# SYNOPSIS
#        suspend-on-close.sh [options]
#
# DESCRIPTION
#        Adds a new "post" event to the ACPI lid close handler
#
# BUGS
#        https://github.com/l0b0/tilde/issues
#
# COPYRIGHT
#        Copyright © 2013-2014 Victor Engmark. License GPLv3+: GNU GPL
#        version 3 or later <http://gnu.org/licenses/gpl.html>.
#        This is free software: you are free to change and redistribute it.
#        There is NO WARRANTY, to the extent permitted by law.
#
################################################################################

set -o errexit -o noclobber -o nounset -o pipefail

directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PATH='/usr/bin:/bin'

target_dir="/etc/acpi/local"
target_file="${target_dir}/lid.sh.post"

if [[ ! -d "$target_dir" ]]
then
    mkdir "$target_dir"
fi

> "$target_file" cat <<EOF
#!/bin/sh
grep -q closed /proc/acpi/button/lid/*/state && pm-suspend
EOF

chmod u+x "$target_file"

答案1

我很确定每次关闭和打开盖子时都会调用您的盖子回调。

文件sleep.sh这里状态:

# if launched through a lid event and lid is open, do nothing
echo "$1" | grep "button/lid" && grep -q open /proc/acpi/button/lid/LID/state && exit 0

“盖子打开”场景是您的脚本未检查的场景之一......

您可以通过将一些参数回显到日志文件来快速测试这一点

答案2

我在 Dell Inspiron 11z 上运行 Awesome WM 和 Ubuntu 14.04,并且遇到了类似的睡眠/挂起问题。

确认s2ram -fs2disk工作后,我更新了/usr/lib/pm-utils/sleep.d/00powersave阅读/usr/sbin/s2ram -f,关闭时暂停,但打开后又暂停。

按照您的指导,我添加了以下内容00powersave

echo "$1" >> /home/user/lid.log
cat /proc/acpi/button/lid/LID0/state >> /home/user/lid.log

关闭并打开笔记本电脑后,输出为:

suspend
state:      closed
resume
state:      open

根据这些状态,我将00powersave文件制作如下:

echo "$1" | grep "resume" && grep -q open /proc/acpi/button/lid/LID0/state && exit 0
/usr/sbin/s2ram -f

它检查脚本是否被“resume”调用以及盖子是否打开,如果满足这两个条件则不执行任何操作。

多谢你们!抱歉,如果这是不礼貌的行为,但解决起来很痛苦,我想发布此内容,以便下一个人可以更轻松地度过。

相关内容