1e41f4b71Sopenharmony_ci# power-shell工具 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_cipower-shell是实现设备电源状态转换等功能的工具,为开发者提供基本的设备电源状态调试能力,例如:熄屏、唤醒、设置电源模式等。 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci## 环境要求 7e41f4b71Sopenharmony_ci<!--RP1--> 8e41f4b71Sopenharmony_ci在使用本工具前,开发者需要先获取[hdc工具](../dfx/hdc.md),执行hdc shell。 9e41f4b71Sopenharmony_ci<!--RP1End--> 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## 命令列表 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci **表1** power-shell工具命令列表 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci| 命令 | 描述 | 16e41f4b71Sopenharmony_ci| -------- | -------- | 17e41f4b71Sopenharmony_ci| help | 帮助命令,显示power-shell支持的命令信息。 | 18e41f4b71Sopenharmony_ci| setmode | 设置电源模式命令,用来设置当前设备的电源模式。 | 19e41f4b71Sopenharmony_ci| wakeup | 亮屏命令,用来唤醒系统并亮屏。 | 20e41f4b71Sopenharmony_ci| suspend | 熄屏命令,用来暂停系统并熄屏。| 21e41f4b71Sopenharmony_ci| timeout | 自动熄屏命令,用来覆盖或恢复系统设置中自动熄屏时间。 | 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci## 帮助命令 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci```bash 27e41f4b71Sopenharmony_cipower-shell help 28e41f4b71Sopenharmony_ci``` 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci **表2** help命令列表 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci| 命令 | 描述 | 33e41f4b71Sopenharmony_ci| ------- | ---------- | 34e41f4b71Sopenharmony_ci| power-shell help | 显示power-shell工具能够支持的命令信息。 | 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci示例: 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci```bash 40e41f4b71Sopenharmony_ci# 显示帮助信息 41e41f4b71Sopenharmony_cipower-shell help 42e41f4b71Sopenharmony_ci``` 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci## 设置电源模式命令 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci```bash 48e41f4b71Sopenharmony_cipower-shell setmode 49e41f4b71Sopenharmony_ci``` 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci **表3** 设置电源模式命令列表 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci| 命令 | 描述 | 54e41f4b71Sopenharmony_ci| ----------------------------------- | -------------------------- | 55e41f4b71Sopenharmony_ci| power-shell setmode -h | 显示setmode支持的命令信息。 | 56e41f4b71Sopenharmony_ci| power-shell setmode 600 | 正常模式。 | 57e41f4b71Sopenharmony_ci| power-shell setmode 601 | 省电模式。 | 58e41f4b71Sopenharmony_ci| power-shell setmode 602 | 性能模式。 | 59e41f4b71Sopenharmony_ci| power-shell setmode 603 | 超级省电模式。 | 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci示例: 62e41f4b71Sopenharmony_ci```bash 63e41f4b71Sopenharmony_ci# 设置设备电源状态为正常模式 64e41f4b71Sopenharmony_cipower-shell setmode 600 65e41f4b71Sopenharmony_ci# 设置设备电源状态为省电模式 66e41f4b71Sopenharmony_cipower-shell setmode 601 67e41f4b71Sopenharmony_ci# 设置设备电源状态为性能模式 68e41f4b71Sopenharmony_cipower-shell setmode 602 69e41f4b71Sopenharmony_ci# 设置设备电源状态为超级省电模式 70e41f4b71Sopenharmony_cipower-shell setmode 603 71e41f4b71Sopenharmony_ci``` 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci## 亮屏命令 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci```bash 77e41f4b71Sopenharmony_cipower-shell wakeup 78e41f4b71Sopenharmony_ci``` 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci **表4** 亮屏命令列表 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci| 命令 | 描述 | 83e41f4b71Sopenharmony_ci| ----------------------------- | ------------------------ | 84e41f4b71Sopenharmony_ci| power-shell wakeup | 亮屏。 | 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci示例: 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci```bash 90e41f4b71Sopenharmony_ci# shell命令亮屏 91e41f4b71Sopenharmony_cipower-shell wakeup 92e41f4b71Sopenharmony_ci``` 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci## 熄屏命令 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci```bash 98e41f4b71Sopenharmony_cipower-shell suspend 99e41f4b71Sopenharmony_ci``` 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci **表5** 熄屏命令列表 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci| 命令 | 描述 | 105e41f4b71Sopenharmony_ci| ---------- | -------------------------- | 106e41f4b71Sopenharmony_ci| power-shell suspend | 熄屏。 | 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci示例: 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ci```bash 112e41f4b71Sopenharmony_ci# shell命令熄屏 113e41f4b71Sopenharmony_cipower-shell suspend 114e41f4b71Sopenharmony_ci``` 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci## 自动熄屏命令 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci```bash 119e41f4b71Sopenharmony_cipower-shell timeout 120e41f4b71Sopenharmony_ci``` 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci **表6** 自动熄屏命令列表 123e41f4b71Sopenharmony_ci| 命令 | 描述 | 124e41f4b71Sopenharmony_ci| ---------- | -------------------------- | 125e41f4b71Sopenharmony_ci| power-shell timeout -o [time] | 设置自动熄屏时间。[time]单位为毫秒。 | 126e41f4b71Sopenharmony_ci| power-shell timeout -r | 恢复到当前系统设置中的自动熄屏时间。 | 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci示例: 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci```bash 131e41f4b71Sopenharmony_ci# 当前系统设置中自动熄屏时间为30秒 132e41f4b71Sopenharmony_ci# shell命令设置自动熄屏时间为15000毫秒 133e41f4b71Sopenharmony_cipower-shell timeout -o 15000 134e41f4b71Sopenharmony_ci# 恢复系统设置的自动熄屏时间,此时自动熄屏时间为30秒 135e41f4b71Sopenharmony_cipower-shell timeout -r 136e41f4b71Sopenharmony_ci``` 137