diff --git a/config/path/max_bri_file.txt b/config/path/max_bri_file.txt
new file mode 100644
index 0000000..beaf703
--- /dev/null
+++ b/config/path/max_bri_file.txt
@@ -0,0 +1 @@
+/sys/class/backlight/panel0-backlight/max_brightness
\ No newline at end of file
diff --git a/config/path/now_bri_file.txt b/config/path/now_bri_file.txt
new file mode 100644
index 0000000..8f88ce9
--- /dev/null
+++ b/config/path/now_bri_file.txt
@@ -0,0 +1 @@
+/sys/class/backlight/panel0-backlight/brightness
\ No newline at end of file
diff --git a/customize.sh b/customize.sh
index 93a27bd..1eb16a6 100755
--- a/customize.sh
+++ b/customize.sh
@@ -1,13 +1,104 @@
#!/system/bin/sh
#shellcheck shell=ash
-now_bri_file="/sys/class/backlight/panel0-backlight/brightness"
-max_bri_file="/sys/class/backlight/panel0-backlight/max_brightness"
+# 默认设备路径(如果路径配置不存在)
+DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
+DEFAULT_MAX_BRI_FILE="/sys/class/backlight/panel0-backlight/max_brightness"
+
mod_config="$MODPATH/config"
+mod_path_config="$mod_config/path"
old_config="/data/adb/modules/LuminPro/config"
+old_path_config="/data/adb/modules/LuminPro/config/path"
# 创建配置目录
[ -d "$mod_config" ] || mkdir -p "$mod_config"
+[ -d "$mod_path_config" ] || mkdir -p "$mod_path_config"
+
+# 获取设备路径函数
+get_device_path() {
+ local path_config="$1"
+ local default_path="$2"
+
+ if [ -f "$path_config" ]; then
+ cat "$path_config"
+ else
+ echo "$default_path"
+ fi
+}
+
+# 初始化全局变量(尝试读取配置,失败则使用默认值)
+now_bri_file="$(get_device_path "$mod_path_config/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")"
+max_bri_file="$(get_device_path "$mod_path_config/max_bri_file.txt" "$DEFAULT_MAX_BRI_FILE")"
+
+# 检查亮度节点文件
+CHECK_FILES() {
+ sleep 1
+
+ # 策略:尝试从多个位置读取配置
+ # 1. 首先从 $MODPATH(安装到设备上的目录)读取
+ # 2. 然后从脚本所在目录读取(压缩包源)
+ # 3. 最后使用默认值
+
+ now_bri_file="$DEFAULT_NOW_BRI_FILE"
+ max_bri_file="$DEFAULT_MAX_BRI_FILE"
+
+ # 尝试从多个来源读取配置文件
+ local now_sources="$mod_path_config/now_bri_file.txt $old_path_config/now_bri_file.txt"
+ local max_sources="$mod_path_config/max_bri_file.txt $old_path_config/max_bri_file.txt"
+
+ # 查找第一个存在的配置文件
+ for source_file in $now_sources; do
+ if [ -f "$source_file" ]; then
+ now_bri_file="$(cat "$source_file")"
+ echo "- 从 $source_file 读取了亮度节点路径"
+ break
+ fi
+ done
+
+ for source_file in $max_sources; do
+ if [ -f "$source_file" ]; then
+ max_bri_file="$(cat "$source_file")"
+ echo "- 从 $source_file 读取了最大亮度节点路径"
+ break
+ fi
+ done
+
+ # 验证路径是否存在
+ echo ""
+ echo "- 尝试验证路径..."
+ echo " - 当前亮度节点: $now_bri_file"
+ echo " - 最大亮度节点: $max_bri_file"
+ echo ""
+
+ if [ -f "$now_bri_file" ] && [ -f "$max_bri_file" ]; then
+ echo "✓ 找到亮度节点文件"
+ else
+ echo "x 未找到亮度节点文件"
+ if [ ! -f "$now_bri_file" ]; then
+ echo " ✗ 当前亮度节点不存在: $now_bri_file"
+ fi
+ if [ ! -f "$max_bri_file" ]; then
+ echo " ✗ 最大亮度节点不存在: $max_bri_file"
+ fi
+ echo ""
+ echo "设备不支持默认路径,需要修改配置"
+ echo "修改方法:"
+ echo " 1. 编辑压缩包内的 config/path/now_bri_file.txt"
+ echo " 2. 编辑压缩包内的 config/path/max_bri_file.txt"
+ echo " 3. 添加你设备的正确亮度节点路径"
+ echo " 4. 重新打包并刷入模块"
+ echo ""
+ echo "查找路径的方法:"
+ echo " find /sys -name '*brightness*' 2>/dev/null | grep -E '(brightness|lcd)'"
+ abort "x 安装中止:无法找到设备亮度节点"
+ fi
+
+ now_bri="$(cat "$now_bri_file")"
+ max_bri="$(cat "$max_bri_file")"
+
+ echo "✓ 当前亮度: $now_bri"
+ echo "✓ 最大亮度: $max_bri"
+}
# 监听音量键函数
button_listener() {
@@ -51,23 +142,6 @@ NOTE() {
fi
}
-# 检查亮度节点文件
-CHECK_FILES() {
- sleep 1
- if [ -f "$now_bri_file" ] && [ -f "$max_bri_file" ]; then
- echo "- 找到亮度节点文件"
- else
- echo "x 未找到亮度节点文件"
- abort "x 暂不支持您的设备"
- fi
-
- now_bri="$(cat "$now_bri_file")"
- max_bri="$(cat "$max_bri_file")"
-
- echo "- 当前亮度: $now_bri"
- echo "- 最大亮度: $max_bri"
-}
-
# 测试前台最大亮度
TEST_UI_MAX_BRI() {
echo ""
@@ -171,6 +245,17 @@ IMPORT_OLD_CONFIG() {
[ -s "$old_config/log_max_size.txt" ] && cp -f "$old_config/log_max_size.txt" "$mod_config/"
[ -s "$old_config/sleep_time.txt" ] && cp -f "$old_config/sleep_time.txt" "$mod_config/"
+ # 迁移旧的路径配置(如果存在)
+ mkdir -p "$mod_path_config"
+ if [ -d "$old_path_config" ]; then
+ [ -s "$old_path_config/now_bri_file.txt" ] && cp -f "$old_path_config/now_bri_file.txt" "$mod_path_config/"
+ [ -s "$old_path_config/max_bri_file.txt" ] && cp -f "$old_path_config/max_bri_file.txt" "$mod_path_config/"
+ else
+ # 创建默认路径配置
+ echo -n "$DEFAULT_NOW_BRI_FILE" >"$mod_path_config/now_bri_file.txt"
+ echo -n "$DEFAULT_MAX_BRI_FILE" >"$mod_path_config/max_bri_file.txt"
+ fi
+
# 版本迁移逻辑
local old_version_code
old_version_code="$(grep_get_prop versionCode "/data/adb/modules/LuminPro/module.prop")"
@@ -195,8 +280,13 @@ IMPORT_OLD_CONFIG() {
# 初始化默认配置文件
INIT_CONFIG() {
mkdir -p "$mod_config"
+ mkdir -p "$mod_path_config"
touch "$mod_config/ui_max_bri.txt"
touch "$mod_config/max_bri.txt"
+
+ # 初始化设备路径配置 (仅在文件不存在时使用默认值,保留用户自定义配置)
+ [ ! -f "$mod_path_config/now_bri_file.txt" ] && echo -n "$DEFAULT_NOW_BRI_FILE" >"$mod_path_config/now_bri_file.txt"
+ [ ! -f "$mod_path_config/max_bri_file.txt" ] && echo -n "$DEFAULT_MAX_BRI_FILE" >"$mod_path_config/max_bri_file.txt"
}
# 补全缺失设置并设定默认值
diff --git a/index.html b/index.html
index 3616c81..8a3747d 100644
--- a/index.html
+++ b/index.html
@@ -26,6 +26,37 @@
+
+
+
+
+
+
+ 当前亮度
+ —
+
+
+ 系统最大亮度
+ —
+
+
+ inotifyd PID
+ —
+
+
+ 休眠状态
+ —
+
+
+
+
-
-