Lenovo XiaoXinAir 14 — 性能模式切换

机型:XiaoxinAir 14ALC 2021 (82LM) / CPU:AMD Ryzen

系统:Debian 13 (trixie) / Kernel 6.12.95 / KDE Plasma

一、功能说明

通过 ACPI platform_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 模式后,可通过以下方式验证:

  1. 查看 CPU 频率上限:

    bash

    复制代码
    cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  2. 观察风扇转速变化:

    bash

    复制代码
    watch -n 1 'sensors | grep -i fan'
  3. 跑分验证:

    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_choices

  • ArchWiki:Lenovo IdeaPad 5 Pro 14ACN6

相关推荐
IMPYLH6 小时前
HTML 的 <wbr> 元素
前端·html
Dovis(誓平步青云)6 小时前
常用命令藏得太深?怎么做一个快捷命令坞
运维·前端·自动化·音视频·prometheus
IT_陈寒7 小时前
Vite的这个问题坑了我三天,原来如此解决!
前端·人工智能·后端
网易云信7 小时前
大模型能上岗做销售吗?我们让 12 款国产模型交了 420 份作业
前端·后端
蜗牛互联网7 小时前
Python Agent工具调用的白名单、参数校验与审批门禁
java·服务器·前端·人工智能·后端·python
计算机魔术师7 小时前
Perplexity:每个 Project 都是一个 Git 仓库
前端
zxanz18 小时前
SSL 证书申请下来快吗?
网络·网络协议·ssl
Andrew5518 小时前
让 AI 写页面不再“一眼假”:我把设计品味做成了一个 Claude Code Skill 流水线
前端
false_or_true8 小时前
一次由 tcp_tw_recycle 引发的“灵异”故障排查:基于双网闸架构的踩坑记
网络·tcp/ip·架构
乐享qicheng8 小时前
14-AI智能管家JSBridge深度问答
前端