使用(Arch、systemd)关闭盖子时笔记本电脑并不总是进入睡眠状态

使用(Arch、systemd)关闭盖子时笔记本电脑并不总是进入睡眠状态

按照 Arch wiki 的说明,我设置了合上盖子的事件,以便机器进入睡眠状态(包括屏幕锁定)。这在 50% 的时间内有效。在其他时候,它会锁定屏幕但不会进入睡眠状态。

我猜一些进程让它保持唤醒状态,但我不知道是哪些进程。有没有办法找出哪些进程让机器保持唤醒状态?

我关注Arch Linux 的 wiki。我最终得到了以下结果:

/etc/systemd/logind.conf

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See logind.conf(5) for details.

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
IdleAction=lock
IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#UserTasksMax=33%

和:/etc/systemd/system/suspend.target.wants/[email protected]

[Unit]
Description=User resume actions
After=suspend.target

[Service]
User=%I
Type=simple
Environment=DISPLAY=:0
# ExecStartPre= -/usr/bin/pkill -u %u unison ; /usr/local/bin/music.sh stop ; /usr/bin/mysql -e 'slave stop'
# ExecStart=/usr/bin/i3lock -c 000022
ExecStart=/usr/bin/slock
ExecStartPost=/usr/bin/sleep 1

[Install]
WantedBy=suspend.target

相关内容