关闭笔记本电脑盖时如何禁用自动暂停?


129

我正在使用archlinux。在最近的系统升级之前,它永远不会自动挂起(也许我更新了内核?)。

我认为它与laptop-mode或有关acpid,所以我停止了它们:

/etc/rc.d/laptop-mode stop
/etc/rc.d/acpid stop

我也编辑/etc/laptop-mode/laptop-mode.conf

ENABLE_LAPTOP_MODE_TOOLS=0

然后我编辑/etc/acpi/actions/lm_lid.sh,注释掉最后一行:

# /usr/sbin/laptop_mode auto

但是以上所有方法都不起作用。发现以下行/var/log/kernel.log(忽略了不相关的行):

Oct 23 15:29:20 localhost kernel: [18617.549098] PM: Syncing filesystems ... done.
Oct 23 15:29:20 localhost kernel: [18618.001898] PM: Preparing system for mem sleep
Oct 23 15:29:30 localhost kernel: [18618.039565] Freezing user space processes ... (elapsed 0.01 seconds) done.
Oct 23 15:29:30 localhost kernel: [18618.052596] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
Oct 23 15:29:30 localhost kernel: [18618.065999] PM: Entering mem sleep
Oct 23 15:29:30 localhost kernel: [18618.066167] Suspending console(s) (use no_console_suspend to debug)
Oct 23 15:29:30 localhost kernel: [18618.097917] sd 0:0:0:0: [sda] Synchronizing SCSI cache
Oct 23 15:29:30 localhost kernel: [18618.098103] sd 0:0:0:0: [sda] Stopping disk
Oct 23 15:29:30 localhost kernel: [18618.270537] snd_hda_intel 0000:00:14.2: power state changed by ACPI to D3hot
Oct 23 15:29:30 localhost kernel: [18619.274374] PM: suspend of devices complete after 1196.192 msecs
Oct 23 15:29:30 localhost kernel: [18619.274691] PM: late suspend of devices complete after 0.313 msecs
Oct 23 15:29:30 localhost kernel: [18619.440877] ohci_hcd 0000:00:14.5: wake-up capability enabled by ACPI
Oct 23 15:29:30 localhost kernel: [18619.642144] ACPI: Waking up from system sleep state S3
Oct 23 15:29:30 localhost kernel: [18620.049424] PM: noirq resume of devices complete after 333.503 msecs
Oct 23 15:29:30 localhost kernel: [18620.049852] PM: early resume of devices complete after 0.334 msecs
Oct 23 15:29:30 localhost kernel: [18622.418605] PM: resume of devices complete after 2371.906 msecs
Oct 23 15:29:30 localhost kernel: [18622.419018] PM: Finishing wakeup.
Oct 23 15:29:30 localhost kernel: [18622.419019] Restarting tasks ... done.
Oct 23 15:29:30 localhost kernel: [18622.464752] video LNXVIDEO:01: Restoring backlight state

我认为这不是由引起的pm-susend,因为/var/log/pm-suspend.log什么都不记录。

关闭盖子时,我不希望笔记本电脑进入睡眠状态。怎么做?

内核版本:3.6.2-1-ARCH


2
当您的问题在“可能已经有了答案的问题”中弹出时,我正要问自己一个问题。它做了。谢谢。
cjm 2012年

1
在Debian 8“ Jessie”上,该命令systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target禁用所有类型的暂停。
CDuv

Answers:


158

编辑/etc/systemd/logind.conf并确保您拥有

HandleLidSwitch=ignore

这将使其忽略关闭的盖子。(您可能还需要撤消所做的其他更改)。

然后,您将需要重新加载logind.conf以使您的更改生效(感谢Ehtesh Choudhury在评论中指出了这一点):

systemctl restart systemd-logind

archlinux Wiki上有完整的详细信息

logind.conf的手册页也包含相关信息,

   HandlePowerKey=, HandleSuspendKey=, HandleHibernateKey=,
   HandleLidSwitch=
       Controls whether logind shall handle the system power and sleep
       keys and the lid switch to trigger actions such as system power-off
       or suspend. Can be one of ignore, poweroff, reboot, halt, kexec,
       suspend, hibernate, hybrid-sleep and lock. If ignore logind will
       never handle these keys. If lock all running sessions will be
       screen locked. Otherwise the specified action will be taken in the
       respective event. Only input devices with the power-switch udev tag
       will be watched for key/lid switch events.  HandlePowerKey=
       defaults to poweroff.  HandleSuspendKey= and HandleLidSwitch=
       default to suspend.  HandleHibernateKey= defaults to hibernate.

16
更改后HandleLidSwitch,如何即时重新加载logind.conf?没关系,是systemctl stop systemd-logind && systemctl start systemd-logind
Ehtesh Choudhury

11
也许systemctl restart systemd-logind,甚至systemctl reload systemd-logind?尚不确定是否足够,因此,在尝试合上盖子之前期待答复(正在进行长时间的计算...(
:)

2
它肯定不在Wiki上了,并且我没有看到logind.conf文章(该页面上的一小部分除外)。
Ehtesh Choudhury 2013年

1
相关主题已移至Arch Wiki上的电源管理

3
systemctl restart systemd-logind导致我的带有GNOME-shell桌面的Archlinux冻结。做好准备
Mehdi Sadeghi

24

您可以使用此功能暂时禁用盖开关事件:

systemd-inhibit --what=handle-lid-switch sleep 1d

3
systemd-inhibit之前从未知道,非常酷
Hubro

我认为它曾经在arch-wiki中发生了。
user3467349

2
handle-lid-switch在这种情况下,这只是禁止特定的命令sleep 1d。但是,通常在合上笔记本电脑盖时不会禁用自动暂停功能。
CMCDragonkai,2016年

3
我写的是您可以使用它来暂时禁用盖开关事件 -这是我或其他人可能想要的。所以我不确定您的评论是关于什么的?
user3467349 '16

1d表示1个日子?如果是这样,还有哪些其他选择?hms?我找不到任何明确解释命令最后部分的内容。
马兰(Marlan)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.