机型:XiaoxinAir 14ALC 2021 (82LM) / CPU:AMD Ryzen
系统:Debian 13 (trixie) / Kernel 6.12.95 / KDE Plasma
一、功能说明
通过 ACPIplatform_profile接口,支持三种性能模式切换:
| 模式 | sysfs 值 | 场景 |
|---|---|---|
| 节能/安静 | low-power | 静音、省电、移动办公 |
| 均衡/智能散热 | balanced | 日常办公、网页浏览 |
| 野兽/性能 | performance | 编译、渲染、游戏 |
二、核心原理
ideapad_laptop内核模块(已加载)通过 ACPI 向系统暴露了platform_profile接口:
bash
cat /sys/firmware/acpi/platform_profile_choices # 输出:low-power balanced performance
切换模式实际上就是向该文件写入对应值:
bash
echo performance | sudo tee /sys/firmware/acpi/platform_profile
内核模块收到写入后,通过 ACPI 方法通知 EC(Embedded Controller),EC 调整风扇曲线、PPT(Package Power Target)和温度墙。
各模式的实际表现
low-power(安静模式):
CPU 温度墙降至 75°C 左右
风扇转速明显降低,几乎听不到风噪
CPU 频率上限被限制,适合轻度办公和移动场景
实测功耗墙降低,省电效果明显
balanced(均衡模式):
温度墙恢复至 85°C 左右
风扇根据负载动态调节
CPU 频率放开至正常范围
适合日常多任务、网页浏览
performance(野兽模式):
温度墙提升至 95°C
风扇转速拉满,风噪明显
CPU 频率可达到最高 Boost
长时间高负载下性能释放更充分
三、使用方法
桌面快捷方式
双击桌面上的“性能模式”图标即可切换,无终端窗口弹出,切换后桌面通知提示当前模式。
命令行
bash
~/bin/xiaoai-profile # 循环切换(节能 → 均衡 → 野兽) ~/bin/xiaoai-profile status # 查看当前模式 ~/bin/xiaoai-profile performance # 直接指定性能模式 ~/bin/xiaoai-profile balanced # 直接指定均衡模式 ~/bin/xiaoai-profile low-power # 直接指定节能模式
判断当前模式
bash
cat /sys/firmware/acpi/platform_profile # 输出 low-power / balanced / performance 之一
手动修改(不推荐)
bash
echo performance | sudo tee /sys/firmware/acpi/platform_profile
四、脚本实现
~/bin/xiaoai-profile:
bash
#!/bin/bash # 循环切换或指定性能模式 PROFILE_FILE="/sys/firmware/acpi/platform_profile" # 检查文件是否存在 if [ ! -f "$PROFILE_FILE" ]; then notify-send "性能模式" "当前设备不支持 platform_profile" -i dialog-error exit 1 fi # 查看当前模式 if [ "$1" = "status" ]; then cat "$PROFILE_FILE" exit 0 fi # 如果指定了模式,直接切换 if [ "$1" = "low-power" ] || [ "$1" = "balanced" ] || [ "$1" = "performance" ]; then echo "$1" | sudo tee "$PROFILE_FILE" > /dev/null notify-send "性能模式" "已切换到 $1" -i preferences-system-performance exit 0 fi # 否则循环切换 CURRENT=$(cat "$PROFILE_FILE") case "$CURRENT" in low-power) NEW="balanced" ICON="preferences-system-performance" ;; balanced) NEW="performance" ICON="preferences-system-performance" ;; performance) NEW="low-power" ICON="battery-low" ;; *) NEW="balanced" ICON="preferences-system-performance" ;; esac echo "$NEW" | sudo tee "$PROFILE_FILE" > /dev/null notify-send "性能模式" "已切换到 $NEW" -i "$ICON"
五、桌面快捷方式
~/桌面/xiaoai-profile.desktop:
ini
[Desktop Entry] Type=Application Name=性能模式 Exec=/home/a1/bin/xiaoai-profile Icon=preferences-system-performance Terminal=false Comment=切换节能/均衡/性能模式
六、权限配置
脚本需要sudo tee写入/sys/firmware/acpi/platform_profile,为免每次弹密码框,添加 sudoers 规则:
bash
# /etc/sudoers.d/xiaoai-profile a1 ALL=(ALL) NOPASSWD: /usr/bin/tee /sys/firmware/acpi/platform_profile
七、验证模式是否生效
切换到 performance 模式后,可通过以下方式验证:
查看 CPU 频率上限:
bash
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
观察风扇转速变化:
bash
watch -n 1 'sensors | grep -i fan'
跑分验证:
bash
stress -c 4 --timeout 30 && sensors
八、常见问题
切换后风扇没有变化?
部分联想机型需要重启ideapad_laptop模块才能让 EC 重新读取模式:
bash
sudo modprobe -r ideapad_laptop && sudo modprobe ideapad_laptop
脚本报错 "Permission denied"?
确认platform_profile文件存在且当前用户有读写权限:
bash
ls -l /sys/firmware/acpi/platform_profile # 通常属主 root:root,权限 644
没有 notification 提示?
确认notify-send已安装且 DBUS_SESSION_BUS_ADDRESS 环境变量存在。桌面快捷方式启动时环境变量可能丢失,脚本开头可加:
bash
export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/$(id -u)/bus}"九、相关文件
| 文件 | 用途 |
|---|---|
~/bin/xiaoai-profile | 主脚本 |
~/桌面/xiaoai-profile.desktop | 桌面快捷方式 |
/etc/sudoers.d/xiaoai-profile | 免密 sudo 配置 |
十、参考资料
内核模块:
ideapad_laptop(已加载)sysfs 路径:
/sys/firmware/acpi/platform_profile可用模式:
cat /sys/firmware/acpi/platform_profile_choicesArchWiki:Lenovo IdeaPad 5 Pro 14ACN6