Systemd是否读取/ etc / pm / …?
在/etc/pm/sleep.d/
使用systemd
读取和执行脚本的系统吗?
我开始总结答案是systemd
忽略了这些脚本。 如果这是真的什么是替代?
更新: man systemd-sleep
状态脚本可以添加到/lib/systemd/system-sleep/
。 细节对我来说不够,但我尝试修改Arch wiki示例并创建了/lib/systemd/system-sleep/root-resume.service
。
[Unit] Description=Local system resume actions After=suspend.target [Service] Type=simple ExecStart=/bin/systemctl restart network-manager.service [Install] WantedBy=suspend.target
我的目的是在恢复后重新启动网络管理器,因为偶尔它不起作用。
这似乎没有做我想要的。
/etc/pm/config.d|power.d|sleep.d
中的脚本在systemd下被忽略。 而是必须创建并启用系统“单元”(服务)。
要在系统从睡眠状态恢复后重新启动网络,我创建了文件/lib/systemd/system/root-resume.service
:
[Unit] Description=Local system resume actions After=suspend.target [Service] Type=oneshot ExecStart=/bin/systemctl restart network-manager.service [Install] WantedBy=suspend.target
然后我用sudo systemctl enable root-resume.service
激活了服务。 启用该服务会在/etc/systemd/system/suspend.target.wants/
为该文件创建符号链接
与man systemd-sleep
/lib/systemd/system-sleep/
中放置的man systemd-sleep
服务文件相反,将被忽略。
不,也不是/usr/lib/pm-utils/sleep.d
那些。 但它运行/lib/systemd/system-sleep/
设置可执行位的所有脚本(不是服务文件)。
这是一个用于调用pm-powersave的示例,它是从/usr/lib/pm-utils/sleep.d/00powersave
修改的。
#!/bin/sh # do not run pm-powersave on ARM during suspend; the 1.5 seconds that it takes # to run it don't nearly compensate the potentially slightly slower suspend # operation in low power mode ARCH=`uname -m` case $1 in pre) [ "$ARCH" != "${ARCH#arm}" ] || pm-powersave false ;; post) pm-powersave ;; esac exit 0
$ 1是简历上的“post”,否则为“pre”。 两种情况下的$ 2都包含“suspend”,“hibernate”或“hybrid-sleep”。