Files
nexus/openclaw/Daily notes/2025-05-13.md

60 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title:
source:
author: shenwei
published:
created:
description: Ubuntu系统中合上笔记本盖子时的行为可以通过修改`systemd-logind`服务的配置来实现
tags: []
---
在Ubuntu系统中合上笔记本盖子时的行为可以通过修改`systemd-logind`服务的配置来实现。以下是详细步骤:
### 步骤 1编辑配置文件
1. **打开终端**,使用文本编辑器(如`nano``vim`)编辑`/etc/systemd/logind.conf`文件:
```bash
sudo nano /etc/systemd/logind.conf
```
2. **找到以下行**(可能被注释掉):
```ini
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
```
3. **修改配置**
- 将`HandleLidSwitch`设置为`ignore`,以禁用合盖时的休眠/挂起。
- 如果需要在外接电源时也禁用此行为,可同时设置`HandleLidSwitchExternalPower=ignore`。
- 取消注释(删除行首的`#`)并修改后的行如下:
```ini
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore # 可选,外接电源时同样忽略
```
### 步骤 2重启服务使配置生效
```bash
sudo systemctl restart systemd-logind.service
```
### 步骤 3验证设置
- 合上笔记本盖子,观察系统是否不再进入休眠/挂起状态。
### 额外说明
- **多用户环境**:如果系统有多个用户登录,可能需要完全重启系统。
- **桌面环境覆盖**某些桌面环境如GNOME可能有自己的电源设置。若上述方法无效请检查
- GNOME`Settings` → `Power` → `When Lid is Closed` 设置为`Do Nothing`。
- 使用以下命令快速设置GNOME
```bash
gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action 'nothing'
gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action 'nothing'
```
### 故障排查
- **配置未生效**:确保编辑`logind.conf`时已取消注释(删除`#`),并重启服务。
- **日志查看**:通过`journalctl -u systemd-logind`检查日志,确认配置是否正确加载。
通过上述步骤,合上笔记本盖子时将不会触发休眠或挂起。