# 防止挂起、休眠状态,禁用以下 systemd 目标。

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
# 将获得以下输出
hybrid-sleep.target
Created symlink /etc/systemd/system/sleep.target → /dev/null.
Created symlink /etc/systemd/system/suspend.target → /dev/null.
Created symlink /etc/systemd/system/hibernate.target → /dev/null.
Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null.
#验证是否生效
sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target

启用挂起和休眠

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
# 获得以下输出
Removed /etc/systemd/system/sleep.target.
Removed /etc/systemd/system/suspend.target.
Removed /etc/systemd/system/hibernate.target.
Removed /etc/systemd/system/hybrid-sleep.target.

防止在合上盖子时进入挂起状态

sudo vim /etc/systemd/logind.conf
[Login] 
HandleLidSwitch=ignore 
HandleLidSwitchDocked=ignore
Edited on

Give me a cup of [coffee]~( ̄▽ ̄)~*

mjw WeChat Pay

WeChat Pay

mjw Alipay

Alipay

mjw PayPal

PayPal