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

相关推荐
子兮曰1 天前
jev-ultrafast 深度解析:7 秒订机票的浏览器 Agent 是如何炼成的
前端·后端·agent
子兮曰1 天前
Jev 爆发一周:7 秒 Agent 背后的 System One 生态与三场争议
前端·后端·ai编程
前端小万1 天前
写公众号赚了 3000 块后,我做了一款叫 "一键成稿" 的软件
前端·微信小程序
爱勇宝1 天前
ZCode 开源 24 小时:一份没有历史的账本,回答不了"有没有偷代码"
前端·后端·chatglm (智谱)
虎头金猫1 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
三十而立洋1 天前
Cookie 详解:从产生到安全,一次讲透
前端·javascript
卡布鲁1 天前
把一个 Vite + Vue3 应用塞进 qiankun (React + Umi3) 主站:十个坑的复盘
前端·javascript·react.js
wuyk5551 天前
《WiFi 嵌入式物联网开发全套实战》| 第 16 章 ESP32 AP+STA 双模共存原理与工程坑点
网络·stm32·物联网
汉堡大王95271 天前
Jev:不是聊天机器人, 而是一个智能 if 语句
前端·人工智能·后端
梦想很大很大1 天前
从运行事实到回归证据:Workrun 的 Telemetry 与 Evaluation 实践
前端·人工智能·后端