创建/etc/systemd/system/resume@.service sudo vim /etc/systemd/system/resume@.service ---------------------------------------------------------------------------------------------------- [Unit] Description=User resume actions After=suspend.target [Service] User=%I Type=simple ExecStart=/usr/bin/deepin-wm-restart.sh [Install] WantedBy=suspend.target 创建/usr/bin/deepin-wm-restart.sh,上面的resume@.service会执行它 sudo vim /usr/bin/deepin-wm-restart.sh -------------------------------------------------------------------------------------------------- #!/bin/bash export DISPLAY=:0 deepin-wm --replace 设置执行权限,设置开机自启服务,并立刻启动 chmod +x /usr/bin/deepin-wm-restart.sh systemctl enable resume@user systemctl start resume@user