暂停立即重新启动 - 使用 systemd 服务编辑 acpi/wakeup

dal*_*eck 4 acpi wakeup systemd 18.04

我的 18.04 Ubuntu Ryzen 桌面会在挂起后立即自行唤醒。我已将问题跟踪到 /proc/acpi/wakeup 在启用的服务列表中,有两个服务(标记为它的价值:AS43 和 PTXH),我可以使用以下 shell 命令禁用它们:

sudo -s 
echo AS43 > /proc/acpi/wakeup
echo PTXH > /proc/acpi/wakeup
Run Code Online (Sandbox Code Playgroud)

完成此操作后 - 系统仅通过键盘输入从睡眠状态唤醒 - 一切都很好。但是我似乎无法自动化这个过程。

一种解决方案(我对其他人持开放态度)是创建一项服务 /etc/systemd/system/suspendfix.service ,如下所示:

[Unit]
Description=fix to prevent system from waking immediately after suspend

[Service]
Type=simple
ExecStartPre=/bin/sh -c '/bin/echo GPP2 > /proc/acpi/wakeup'
ExecStart=/bin/sh -c '/bin/echo AS43 > /proc/acpi/wakeup'
ExecStartPost=/bin/sh -c '/bin/echo PTXH > /proc/acpi/wakeup'
RemainAfterExit=yes
TimeoutSec=90s

[Install]
WantedBy=sleep.target
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用。要么是我的服务脚本不正确,要么是某些东西正在将有问题的 AS43 和 PTXH 翻转回启用状态,而不管此 systemd 服务文件如何。任何帮助,非常感谢!~~

小智 5

我的 Lenovo Yoga 910 上有同样的问题(USB 重新唤醒)。使用mike-g2 (mikeg-utk) 的解决方案解决了:

  1. 创建文件:/etc/systemd/system/toggle.XHC.to.fix.suspend.issue.service 包含以下内容:

    [Unit]
    Description="Make suspend ignore USB wake up."
    
    [Service]
    ExecStart=/bin/bash -c "echo XHC >> /proc/acpi/wakeup"
    
    [Install]
    WantedBy=multi-user.target
    
    Run Code Online (Sandbox Code Playgroud)
  2. 在 /etc/systemd/system/multi-user.target.wants/ 中创建指向上述脚本的符号链接

    ln -s /etc/systemd/system/toggle.XHC.to.fix.suspend.issue.service /etc/systemd/system/multi-user.target.wants/
    
    Run Code Online (Sandbox Code Playgroud)
  3. 启动服务

    sudo systemctl daemon-reload
    sudo systemctl start toggle.XHC.to.fix.suspend.issue.service
    
    Run Code Online (Sandbox Code Playgroud)
  4. 检查服务是否启动

    sudo systemctl status toggle.XHC.to.fix.suspend.issue.service
    
    Run Code Online (Sandbox Code Playgroud)
  5. 在启动时启用它

    sudo systemctl enable toggle.XHC.to.fix.suspend.issue.service
    
    Run Code Online (Sandbox Code Playgroud)