mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
chore: 支持自定义文件设备路径
This commit is contained in:
1 parent
1e860b8a56
commit
a6bfba9647
13 files changed
+375
-82
No files matched your search
@@ -0,0 +1 @@
|
||||
/sys/class/backlight/panel0-backlight/max_brightness
|
||||
@@ -0,0 +1 @@
|
||||
/sys/class/backlight/panel0-backlight/brightness
|
||||
+109
-19
@@ -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"
|
||||
}
|
||||
|
||||
# 补全缺失设置并设定默认值
|
||||
|
||||
+59
-24
@@ -26,6 +26,37 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 实时状态 -->
|
||||
<section class="card" id="status-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="activity"></i></span>
|
||||
<h2>实时状态</h2>
|
||||
<div class="header-actions">
|
||||
<button class="btn-text-s" id="btn-toggle-service">暂停</button>
|
||||
<button class="btn-text-s" id="btn-restart-service">重启</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<span class="status-label">当前亮度</span>
|
||||
<span class="status-value" id="status-current-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">系统最大亮度</span>
|
||||
<span class="status-value" id="status-sys-max-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">inotifyd PID</span>
|
||||
<span class="status-value" id="status-inotifyd-pid">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">休眠状态</span>
|
||||
<span class="status-value" id="status-sleep">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 配置卡片 -->
|
||||
<section class="card" id="config-section">
|
||||
<div class="card-header">
|
||||
@@ -133,34 +164,38 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 实时状态 -->
|
||||
<section class="card" id="status-section">
|
||||
<!-- 高级设置卡片 -->
|
||||
<section class="card" id="advanced-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="activity"></i></span>
|
||||
<h2>实时状态</h2>
|
||||
<div class="header-actions">
|
||||
<button class="btn-text-s" id="btn-toggle-service">暂停</button>
|
||||
<button class="btn-text-s" id="btn-restart-service">重启</button>
|
||||
<span class="card-icon"><i data-lucide="sliders"></i></span>
|
||||
<h2>高级设置</h2>
|
||||
</div>
|
||||
|
||||
<div class="config-group">
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">当前亮度节点</span>
|
||||
<span class="config-desc">修改需重启服务</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="text" id="input-now-bri-file" class="config-input config-input-wide" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">最大亮度节点</span>
|
||||
<span class="config-desc">修改需重启服务</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="text" id="input-sys-max-bri-file" class="config-input config-input-wide" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<span class="status-label">当前亮度</span>
|
||||
<span class="status-value" id="status-current-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">系统最大亮度</span>
|
||||
<span class="status-value" id="status-sys-max-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">inotifyd PID</span>
|
||||
<span class="status-value" id="status-inotifyd-pid">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">休眠状态</span>
|
||||
<span class="status-value" id="status-sleep">—</span>
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<button class="btn btn-primary" id="btn-save-advanced">
|
||||
<span class="btn-icon"><i data-lucide="save"></i></span> 保存设置
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
id=LuminPro
|
||||
name=LuminPro丨日用屏幕亮度强化
|
||||
version=V2.2
|
||||
versionCode=2202
|
||||
versionCode=2203
|
||||
author=酷安@Yule
|
||||
description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果
|
||||
updateJson=https://share.yule.ink/magisk/mod/luminpro/update.json
|
||||
+47
-1
@@ -7,11 +7,33 @@ SCRIPT_DIR="$(dirname "$REAL_PATH")"
|
||||
MODDIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
PID_DIR="$MODDIR/pid"
|
||||
CONFIG_DIR="$MODDIR/config"
|
||||
PATH_CONFIG_DIR="$CONFIG_DIR/path"
|
||||
pid_file="$PID_DIR/inotifyd.pid"
|
||||
stop_file="$PID_DIR/stop.flag"
|
||||
pause_file="$PID_DIR/daemon.pause"
|
||||
log_file="$MODDIR/service.log"
|
||||
now_bri_file="/sys/class/backlight/panel0-backlight/brightness"
|
||||
config_cache_file="$PID_DIR/.config_cache"
|
||||
|
||||
# 默认设备路径
|
||||
DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
|
||||
|
||||
# 读取配置函数
|
||||
get_config() {
|
||||
local config_file="$1"
|
||||
local default_value="$2"
|
||||
if [ -f "$config_file" ]; then
|
||||
cat "$config_file"
|
||||
else
|
||||
echo "$default_value"
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取当前配置的哈希值(用于检测配置变化)
|
||||
get_config_hash() {
|
||||
local now_file="$(get_config "$PATH_CONFIG_DIR/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")"
|
||||
echo "$now_file"
|
||||
}
|
||||
|
||||
# 日志函数
|
||||
_log() {
|
||||
@@ -39,14 +61,38 @@ while true; do
|
||||
continue
|
||||
fi
|
||||
|
||||
# 获取当前配置
|
||||
current_config="$(get_config_hash)"
|
||||
|
||||
# 检查配置是否改变
|
||||
if [ -f "$config_cache_file" ]; then
|
||||
cached_config="$(cat "$config_cache_file")"
|
||||
if [ "$current_config" != "$cached_config" ]; then
|
||||
_log "检测到配置文件改变,将重启 inotifyd..."
|
||||
[ -f "$pid_file" ] && kill -9 "$(cat "$pid_file")" 2>/dev/null
|
||||
rm -f "$pid_file"
|
||||
echo "$current_config" >"$config_cache_file"
|
||||
sleep 1
|
||||
continue
|
||||
fi
|
||||
else
|
||||
# 第一次启动或缓存不存在,保存当前配置
|
||||
echo "$current_config" >"$config_cache_file"
|
||||
fi
|
||||
|
||||
# 正常启动并监听
|
||||
_log "启动 inotifyd 监听任务..."
|
||||
now_bri_file="$current_config"
|
||||
|
||||
# 更新缓存,让 up.sh 知道当前监听的是哪个文件
|
||||
echo -n "$now_bri_file" >"$PATH_CONFIG_DIR/.cached_path"
|
||||
|
||||
# 启动并重定向 (不再使用子进程管道以保证 PID 抓取准确)
|
||||
inotifyd "$MODDIR/script/up.sh" "$now_bri_file:c" >>"$log_file" 2>&1 &
|
||||
|
||||
inotify_pid=$!
|
||||
echo "$inotify_pid" >"$pid_file"
|
||||
_log "inotifyd 启动,PID: $inotify_pid,监听文件: $now_bri_file"
|
||||
|
||||
# 3. 通过 wait 阻塞,实时感知进程死亡 (兼容所有 BusyBox 环境)
|
||||
wait "$inotify_pid"
|
||||
|
||||
+29
-4
@@ -4,12 +4,31 @@
|
||||
|
||||
MODDIR="${0%/*/*}"
|
||||
CONFIG_DIR="$MODDIR/config"
|
||||
PATH_CONFIG_DIR="$CONFIG_DIR/path"
|
||||
PID_DIR="$MODDIR/pid"
|
||||
flag_file="$PID_DIR/up.flag"
|
||||
stop_file="$PID_DIR/stop.flag"
|
||||
log_file="$MODDIR/service.log"
|
||||
pause_file="$PID_DIR/daemon.pause"
|
||||
now_bri_file="/sys/class/backlight/panel0-backlight/brightness"
|
||||
|
||||
# 默认设备路径
|
||||
DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
|
||||
DEFAULT_MAX_BRI_FILE="/sys/class/backlight/panel0-backlight/max_brightness"
|
||||
|
||||
# 读取配置函数
|
||||
get_config() {
|
||||
local config_file="$1"
|
||||
local default_value="$2"
|
||||
if [ -f "$config_file" ]; then
|
||||
cat "$config_file"
|
||||
else
|
||||
echo "$default_value"
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取亮度文件路径
|
||||
now_bri_file="$(get_config "$PATH_CONFIG_DIR/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")"
|
||||
max_bri_file="$(get_config "$PATH_CONFIG_DIR/max_bri_file.txt" "$DEFAULT_MAX_BRI_FILE")"
|
||||
|
||||
# 日志函数
|
||||
_log() {
|
||||
@@ -47,9 +66,6 @@ if [ -f "$flag_file" ]; then
|
||||
fi
|
||||
touch "$flag_file"
|
||||
|
||||
# 节点文件
|
||||
now_bri_file="/sys/class/backlight/panel0-backlight/brightness"
|
||||
|
||||
# 读取配置 (均为数值)
|
||||
ui_max_bri="$(cat "$CONFIG_DIR/ui_max_bri.txt")"
|
||||
max_bri="$(cat "$CONFIG_DIR/max_bri.txt")"
|
||||
@@ -171,6 +187,15 @@ MAIN() {
|
||||
CHECK_BRI
|
||||
rm -f "$flag_file" # 删除成果锁
|
||||
rm -f "$pause_file" # 解锁守护进程,让它自动拉起 inotifyd
|
||||
|
||||
# 如果配置文件被修改了,杀掉 inotifyd 让 daemon 重启并重新读取配置
|
||||
local current_now_bri="$(cat "$PATH_CONFIG_DIR/now_bri_file.txt" 2>/dev/null || echo "$DEFAULT_NOW_BRI_FILE")"
|
||||
local cached_now_bri="$(cat "$PATH_CONFIG_DIR/.cached_path" 2>/dev/null || echo "$DEFAULT_NOW_BRI_FILE")"
|
||||
|
||||
if [ "$current_now_bri" != "$cached_now_bri" ]; then
|
||||
_log "[$$] 检测到设备路径配置已改变,重启 inotifyd..."
|
||||
killall -9 inotifyd 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
MAIN
|
||||
|
||||
+22
@@ -3,8 +3,24 @@
|
||||
|
||||
MODDIR="${0%/*}"
|
||||
CONFIG_DIR="$MODDIR/config"
|
||||
PATH_CONFIG_DIR="$CONFIG_DIR/path"
|
||||
log_file="$MODDIR/service.log"
|
||||
|
||||
# 默认设备路径
|
||||
DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
|
||||
DEFAULT_MAX_BRI_FILE="/sys/class/backlight/panel0-backlight/max_brightness"
|
||||
|
||||
# 读取配置函数
|
||||
get_config() {
|
||||
local config_file="$1"
|
||||
local default_value="$2"
|
||||
if [ -f "$config_file" ]; then
|
||||
cat "$config_file"
|
||||
else
|
||||
echo "$default_value"
|
||||
fi
|
||||
}
|
||||
|
||||
_log() {
|
||||
printf '[%s] [service] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file"
|
||||
}
|
||||
@@ -17,6 +33,12 @@ _log "- 前台最大亮度: $(cat "$CONFIG_DIR/ui_max_bri.txt")"
|
||||
_log "- 峰值最大亮度: $(cat "$CONFIG_DIR/max_bri.txt")"
|
||||
_log "- 休眠时间: $(cat "$CONFIG_DIR/sleep_time.txt")"
|
||||
|
||||
# 读取设备路径配置
|
||||
now_bri_file="$(get_config "$PATH_CONFIG_DIR/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")"
|
||||
max_bri_file="$(get_config "$PATH_CONFIG_DIR/max_bri_file.txt" "$DEFAULT_MAX_BRI_FILE")"
|
||||
_log "- 当前亮度节点: $now_bri_file"
|
||||
_log "- 最大亮度节点: $max_bri_file"
|
||||
|
||||
_log "LuminPro 启动守护监控..."
|
||||
chmod 755 "$MODDIR/script/up.sh"
|
||||
chmod 755 "$MODDIR/script/daemon.sh"
|
||||
|
||||
+40
-2
@@ -2,13 +2,17 @@ import { exec } from 'kernelsu';
|
||||
import { createIcons, Sun, Settings, Save, Activity, RefreshCw, FileText } from 'lucide';
|
||||
|
||||
const CONFIG_DIR = '/data/adb/modules/LuminPro/config';
|
||||
const PATH_CONFIG_DIR = '/data/adb/modules/LuminPro/config/path';
|
||||
const BACKUP_DIR = '/data/adb/modules/LuminPro/config/.backup';
|
||||
const PID_FILE = '/data/adb/modules/LuminPro/pid/inotifyd.pid';
|
||||
const FLAG_FILE = '/data/adb/modules/LuminPro/pid/up.flag';
|
||||
const STOP_FLAG_FILE = '/data/adb/modules/LuminPro/pid/stop.flag';
|
||||
const LOG_FILE = '/data/adb/modules/LuminPro/service.log';
|
||||
const NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness';
|
||||
const SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness';
|
||||
const DEFAULT_NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness';
|
||||
const DEFAULT_SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness';
|
||||
|
||||
let NOW_BRI_FILE = DEFAULT_NOW_BRI_FILE;
|
||||
let SYS_MAX_BRI_FILE = DEFAULT_SYS_MAX_BRI_FILE;
|
||||
|
||||
// ==========================
|
||||
// 工具函数
|
||||
@@ -43,6 +47,16 @@ async function writeFile(path, content) {
|
||||
|
||||
// 1. 加载配置
|
||||
async function loadConfig() {
|
||||
// 首先加载设备路径配置
|
||||
const [pathNowRes, pathMaxRes] = await Promise.all([
|
||||
runCmd(`cat "${PATH_CONFIG_DIR}/now_bri_file.txt"`),
|
||||
runCmd(`cat "${PATH_CONFIG_DIR}/max_bri_file.txt"`)
|
||||
]);
|
||||
|
||||
if (pathNowRes.errno === 0) NOW_BRI_FILE = pathNowRes.stdout.trim();
|
||||
if (pathMaxRes.errno === 0) SYS_MAX_BRI_FILE = pathMaxRes.stdout.trim();
|
||||
|
||||
// 然后加载其他配置
|
||||
const [uiRes, maxRes, sleepRes, autoRes, stepsRes, logSizeRes] = await Promise.all([
|
||||
runCmd(`cat "${CONFIG_DIR}/ui_max_bri.txt"`),
|
||||
runCmd(`cat "${CONFIG_DIR}/max_bri.txt"`),
|
||||
@@ -55,6 +69,10 @@ async function loadConfig() {
|
||||
if (uiRes.errno === 0) document.getElementById('input-ui-max-bri').value = uiRes.stdout.trim();
|
||||
if (maxRes.errno === 0) document.getElementById('input-max-bri').value = maxRes.stdout.trim();
|
||||
|
||||
// 加载高级设置中的设备路径
|
||||
document.getElementById('input-now-bri-file').value = NOW_BRI_FILE;
|
||||
document.getElementById('input-sys-max-bri-file').value = SYS_MAX_BRI_FILE;
|
||||
|
||||
if (sleepRes.errno === 0) {
|
||||
const timeVal = sleepRes.stdout.trim();
|
||||
const modeSwitch = document.getElementById('input-sleep-mode');
|
||||
@@ -149,6 +167,25 @@ async function saveConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
// 2.2 保存高级设置(设备路径)
|
||||
async function saveAdvancedConfig() {
|
||||
const nowBriFile = document.getElementById('input-now-bri-file').value || DEFAULT_NOW_BRI_FILE;
|
||||
const sysMaxBriFile = document.getElementById('input-sys-max-bri-file').value || DEFAULT_SYS_MAX_BRI_FILE;
|
||||
|
||||
showToast('保存中...');
|
||||
|
||||
// 保存设备路径配置
|
||||
const pathChanged = (NOW_BRI_FILE !== nowBriFile) || (SYS_MAX_BRI_FILE !== sysMaxBriFile);
|
||||
await writeFile(`${PATH_CONFIG_DIR}/now_bri_file.txt`, nowBriFile);
|
||||
await writeFile(`${PATH_CONFIG_DIR}/max_bri_file.txt`, sysMaxBriFile);
|
||||
|
||||
if (pathChanged) {
|
||||
showToast('设备路径已修改,需要重启服务生效');
|
||||
} else {
|
||||
showToast('设置已保存');
|
||||
}
|
||||
}
|
||||
|
||||
// 2.5 恢复默认
|
||||
let isResetConfirming = false;
|
||||
let resetTimer = null;
|
||||
@@ -355,6 +392,7 @@ async function init() {
|
||||
|
||||
// 绑定事件
|
||||
document.getElementById('btn-save').addEventListener('click', saveConfig);
|
||||
document.getElementById('btn-save-advanced').addEventListener('click', saveAdvancedConfig);
|
||||
document.getElementById('btn-reset').addEventListener('click', handleReset);
|
||||
document.getElementById('btn-toggle-service').addEventListener('click', toggleService);
|
||||
document.getElementById('btn-restart-service').addEventListener('click', restartService);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"versionCode": 2202,
|
||||
"versionCode": 2203,
|
||||
"version": "V2.2",
|
||||
"zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2202.zip",
|
||||
"zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2203.zip",
|
||||
"changelog": "https://share.yule.ink/magisk/mod/luminpro/changelog.md"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=0;function t(t){return`${t}_callback_${Date.now()}_${e++}`}function n(e,n){return n===void 0&&(n={}),new Promise((r,i)=>{let a=t(`exec`);window[a]=(e,t,n)=>{r({errno:e,stdout:t,stderr:n}),o(a)};function o(e){delete window[e]}try{ksu.exec(e,JSON.stringify(n),a)}catch(e){i(e),o(a)}})}function r(){this.listeners={}}r.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},r.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};function i(){this.listeners={},this.stdin=new r,this.stdout=new r,this.stderr=new r}i.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},i.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};var a={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},o=([e,t,n])=>{let r=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(t).forEach(e=>{r.setAttribute(e,String(t[e]))}),n?.length&&n.forEach(e=>{let t=o(e);r.appendChild(t)}),r},s=(e,t={})=>o([`svg`,{...a,...t},e]),c=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},l=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),u=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),d=e=>{let t=u(e);return t.charAt(0).toUpperCase()+t.slice(1)},f=e=>Array.from(e.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),p=e=>typeof e==`string`?e:!e||!e.class?``:e.class&&typeof e.class==`string`?e.class.split(` `):e.class&&Array.isArray(e.class)?e.class:``,m=(e,{nameAttr:t,icons:n,attrs:r})=>{let i=e.getAttribute(t);if(i==null)return;let o=n[d(i)];if(!o)return console.warn(`${e.outerHTML} icon name was not found in the provided icons object.`);let u=f(e),m=c(u)?{}:{"aria-hidden":`true`},h={...a,"data-lucide":i,...m,...r,...u},g=p(u),_=p(r),v=l(`lucide`,`lucide-${i}`,...g,..._);v&&Object.assign(h,{class:v});let y=s(o,h);return e.parentNode?.replaceChild(y,e)},h=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],g=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],_=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],v=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],y=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],b=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],x=({icons:e={},nameAttr:t=`data-lucide`,attrs:n={},root:r=document,inTemplates:i}={})=>{if(!Object.values(e).length)throw Error(`Please provide an icons object.
|
||||
If you want to use all the icons you can import it like:
|
||||
\`import { createIcons, icons } from 'lucide';
|
||||
lucide.createIcons({icons});\``);if(r===void 0)throw Error("`createIcons()` only works in a browser environment.");if(Array.from(r.querySelectorAll(`[${t}]`)).forEach(r=>m(r,{nameAttr:t,icons:e,attrs:n})),i&&Array.from(r.querySelectorAll(`template`)).forEach(r=>x({icons:e,nameAttr:t,attrs:n,root:r.content,inTemplates:i})),t===`data-lucide`){let t=r.querySelectorAll(`[icon-name]`);t.length>0&&(console.warn(`[Lucide] Some icons were found with the now deprecated icon-name attribute. These will still be replaced for backwards compatibility, but will no longer be supported in v1.0 and you should switch to data-lucide`),Array.from(t).forEach(t=>m(t,{nameAttr:`icon-name`,icons:e,attrs:n})))}},S=`/data/adb/modules/LuminPro/config`,C=`/data/adb/modules/LuminPro/config/path`,w=`/data/adb/modules/LuminPro/config/.backup`,T=`/data/adb/modules/LuminPro/pid/inotifyd.pid`,E=`/data/adb/modules/LuminPro/pid/up.flag`,D=`/data/adb/modules/LuminPro/pid/stop.flag`,O=`/data/adb/modules/LuminPro/service.log`,k=`/sys/class/backlight/panel0-backlight/brightness`,A=`/sys/class/backlight/panel0-backlight/max_brightness`,j=k,M=A;function N(e){let t=document.getElementById(`toast`);t.textContent=e,t.classList.add(`show`),setTimeout(()=>t.classList.remove(`show`),3e3)}async function P(e){try{return await n(e)}catch(e){return console.error(e),{errno:-1,stdout:``,stderr:String(e)}}}async function F(e,t){return P(`echo -n '${String(t).replace(/'/g,`'\\''`)}' > "${e}"`)}async function I(){let[e,t]=await Promise.all([P(`cat "${C}/now_bri_file.txt"`),P(`cat "${C}/max_bri_file.txt"`)]);e.errno===0&&(j=e.stdout.trim()),t.errno===0&&(M=t.stdout.trim());let[n,r,i,a,o,s]=await Promise.all([P(`cat "${S}/ui_max_bri.txt"`),P(`cat "${S}/max_bri.txt"`),P(`cat "${S}/sleep_time.txt"`),P(`cat "${S}/auto_bri_sleep.txt"`),P(`cat "${S}/steps_num.txt"`),P(`cat "${S}/log_max_size.txt"`)]);if(n.errno===0&&(document.getElementById(`input-ui-max-bri`).value=n.stdout.trim()),r.errno===0&&(document.getElementById(`input-max-bri`).value=r.stdout.trim()),document.getElementById(`input-now-bri-file`).value=j,document.getElementById(`input-sys-max-bri-file`).value=M,i.errno===0){let e=i.stdout.trim(),t=document.getElementById(`input-sleep-mode`),n=document.getElementById(`sleep-time-expand`);if(e&&e.includes(`-`)){t.checked=!0,n.classList.add(`show`);let[r,i]=e.split(`-`);r.length===4&&(document.getElementById(`input-sleep-start-h`).value=r.slice(0,2),document.getElementById(`input-sleep-start-m`).value=r.slice(2)),i.length===4&&(document.getElementById(`input-sleep-end-h`).value=i.slice(0,2),document.getElementById(`input-sleep-end-m`).value=i.slice(2))}else t.checked=!1,n.classList.remove(`show`),document.getElementById(`input-sleep-start-h`).value=`19`,document.getElementById(`input-sleep-start-m`).value=`00`,document.getElementById(`input-sleep-end-h`).value=`06`,document.getElementById(`input-sleep-end-m`).value=`00`}if(a.errno===0&&(document.getElementById(`input-auto-bri-sleep`).checked=a.stdout.trim()===`1`),o.errno===0){let e=o.stdout.trim();document.getElementById(`input-steps-num`).value=e||`50`}else document.getElementById(`input-steps-num`).value=`50`;if(s.errno===0){let e=s.stdout.trim();document.getElementById(`input-log-max-size`).value=e||`500`}else document.getElementById(`input-log-max-size`).value=`500`}async function L(){let e=document.getElementById(`input-ui-max-bri`).value,t=document.getElementById(`input-max-bri`).value,n=e=>String(e).padStart(2,`0`),r=document.getElementById(`input-sleep-mode`).checked,i=``;r&&(i=`${n(document.getElementById(`input-sleep-start-h`).value)}${n(document.getElementById(`input-sleep-start-m`).value)}-${n(document.getElementById(`input-sleep-end-h`).value)}${n(document.getElementById(`input-sleep-end-m`).value)}`);let a=document.getElementById(`input-auto-bri-sleep`).checked?`1`:`0`,o=document.getElementById(`input-steps-num`).value||`50`,s=document.getElementById(`input-log-max-size`).value||`500`;if(!e||!t){N(`亮度值不能为空`);return}N(`保存中...`),await F(`${S}/ui_max_bri.txt`,e),await F(`${S}/max_bri.txt`,t),await F(`${S}/sleep_time.txt`,i),await F(`${S}/auto_bri_sleep.txt`,a),await F(`${S}/steps_num.txt`,o),await F(`${S}/log_max_size.txt`,s),await P(`rm -f "${E}"`);let c=await P(`cat "${T}"`);c.errno===0&&c.stdout.trim()?N(`配置已保存 (可能需要在下次调整时生效)`):N(`配置已保存 (服务未运行)`)}async function R(){let e=document.getElementById(`input-now-bri-file`).value||k,t=document.getElementById(`input-sys-max-bri-file`).value||A;N(`保存中...`);let n=j!==e||M!==t;await F(`${C}/now_bri_file.txt`,e),await F(`${C}/max_bri_file.txt`,t),N(n?`设备路径已修改,需要重启服务生效`:`设置已保存`)}var z=!1,B=null;function V(){let e=document.getElementById(`btn-reset`);e.textContent=`恢复默认`,e.classList.remove(`btn-danger`),z=!1,B&&clearTimeout(B)}async function H(){let e=document.getElementById(`btn-reset`);if(!z){z=!0,e.textContent=`确认`,e.classList.addLine truncated
|
||||
@@ -1,4 +0,0 @@
|
||||
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=0;function t(t){return`${t}_callback_${Date.now()}_${e++}`}function n(e,n){return n===void 0&&(n={}),new Promise((r,i)=>{let a=t(`exec`);window[a]=(e,t,n)=>{r({errno:e,stdout:t,stderr:n}),o(a)};function o(e){delete window[e]}try{ksu.exec(e,JSON.stringify(n),a)}catch(e){i(e),o(a)}})}function r(){this.listeners={}}r.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},r.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};function i(){this.listeners={},this.stdin=new r,this.stdout=new r,this.stderr=new r}i.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},i.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};var a={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},o=([e,t,n])=>{let r=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(t).forEach(e=>{r.setAttribute(e,String(t[e]))}),n?.length&&n.forEach(e=>{let t=o(e);r.appendChild(t)}),r},s=(e,t={})=>o([`svg`,{...a,...t},e]),c=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},l=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),u=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),d=e=>{let t=u(e);return t.charAt(0).toUpperCase()+t.slice(1)},f=e=>Array.from(e.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),p=e=>typeof e==`string`?e:!e||!e.class?``:e.class&&typeof e.class==`string`?e.class.split(` `):e.class&&Array.isArray(e.class)?e.class:``,m=(e,{nameAttr:t,icons:n,attrs:r})=>{let i=e.getAttribute(t);if(i==null)return;let o=n[d(i)];if(!o)return console.warn(`${e.outerHTML} icon name was not found in the provided icons object.`);let u=f(e),m=c(u)?{}:{"aria-hidden":`true`},h={...a,"data-lucide":i,...m,...r,...u},g=p(u),_=p(r),v=l(`lucide`,`lucide-${i}`,...g,..._);v&&Object.assign(h,{class:v});let y=s(o,h);return e.parentNode?.replaceChild(y,e)},h=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],g=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],_=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],v=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],y=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],b=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],x=({icons:e={},nameAttr:t=`data-lucide`,attrs:n={},root:r=document,inTemplates:i}={})=>{if(!Object.values(e).length)throw Error(`Please provide an icons object.
|
||||
If you want to use all the icons you can import it like:
|
||||
\`import { createIcons, icons } from 'lucide';
|
||||
lucide.createIcons({icons});\``);if(r===void 0)throw Error("`createIcons()` only works in a browser environment.");if(Array.from(r.querySelectorAll(`[${t}]`)).forEach(r=>m(r,{nameAttr:t,icons:e,attrs:n})),i&&Array.from(r.querySelectorAll(`template`)).forEach(r=>x({icons:e,nameAttr:t,attrs:n,root:r.content,inTemplates:i})),t===`data-lucide`){let t=r.querySelectorAll(`[icon-name]`);t.length>0&&(console.warn(`[Lucide] Some icons were found with the now deprecated icon-name attribute. These will still be replaced for backwards compatibility, but will no longer be supported in v1.0 and you should switch to data-lucide`),Array.from(t).forEach(t=>m(t,{nameAttr:`icon-name`,icons:e,attrs:n})))}},S=`/data/adb/modules/LuminPro/config`,C=`/data/adb/modules/LuminPro/config/.backup`,w=`/data/adb/modules/LuminPro/pid/inotifyd.pid`,T=`/data/adb/modules/LuminPro/pid/up.flag`,E=`/data/adb/modules/LuminPro/pid/stop.flag`,D=`/data/adb/modules/LuminPro/service.log`,O=`/sys/class/backlight/panel0-backlight/brightness`,k=`/sys/class/backlight/panel0-backlight/max_brightness`;function A(e){let t=document.getElementById(`toast`);t.textContent=e,t.classList.add(`show`),setTimeout(()=>t.classList.remove(`show`),3e3)}async function j(e){try{return await n(e)}catch(e){return console.error(e),{errno:-1,stdout:``,stderr:String(e)}}}async function M(e,t){return j(`echo -n '${String(t).replace(/'/g,`'\\''`)}' > "${e}"`)}async function N(){let[e,t,n,r,i,a]=await Promise.all([j(`cat "${S}/ui_max_bri.txt"`),j(`cat "${S}/max_bri.txt"`),j(`cat "${S}/sleep_time.txt"`),j(`cat "${S}/auto_bri_sleep.txt"`),j(`cat "${S}/steps_num.txt"`),j(`cat "${S}/log_max_size.txt"`)]);if(e.errno===0&&(document.getElementById(`input-ui-max-bri`).value=e.stdout.trim()),t.errno===0&&(document.getElementById(`input-max-bri`).value=t.stdout.trim()),n.errno===0){let e=n.stdout.trim(),t=document.getElementById(`input-sleep-mode`),r=document.getElementById(`sleep-time-expand`);if(e&&e.includes(`-`)){t.checked=!0,r.classList.add(`show`);let[n,i]=e.split(`-`);n.length===4&&(document.getElementById(`input-sleep-start-h`).value=n.slice(0,2),document.getElementById(`input-sleep-start-m`).value=n.slice(2)),i.length===4&&(document.getElementById(`input-sleep-end-h`).value=i.slice(0,2),document.getElementById(`input-sleep-end-m`).value=i.slice(2))}else t.checked=!1,r.classList.remove(`show`),document.getElementById(`input-sleep-start-h`).value=`19`,document.getElementById(`input-sleep-start-m`).value=`00`,document.getElementById(`input-sleep-end-h`).value=`06`,document.getElementById(`input-sleep-end-m`).value=`00`}if(r.errno===0&&(document.getElementById(`input-auto-bri-sleep`).checked=r.stdout.trim()===`1`),i.errno===0){let e=i.stdout.trim();document.getElementById(`input-steps-num`).value=e||`50`}else document.getElementById(`input-steps-num`).value=`50`;if(a.errno===0){let e=a.stdout.trim();document.getElementById(`input-log-max-size`).value=e||`500`}else document.getElementById(`input-log-max-size`).value=`500`}async function P(){let e=document.getElementById(`input-ui-max-bri`).value,t=document.getElementById(`input-max-bri`).value,n=e=>String(e).padStart(2,`0`),r=document.getElementById(`input-sleep-mode`).checked,i=``;r&&(i=`${n(document.getElementById(`input-sleep-start-h`).value)}${n(document.getElementById(`input-sleep-start-m`).value)}-${n(document.getElementById(`input-sleep-end-h`).value)}${n(document.getElementById(`input-sleep-end-m`).value)}`);let a=document.getElementById(`input-auto-bri-sleep`).checked?`1`:`0`,o=document.getElementById(`input-steps-num`).value||`50`,s=document.getElementById(`input-log-max-size`).value||`500`;if(!e||!t){A(`亮度值不能为空`);return}A(`保存中...`),await M(`${S}/ui_max_bri.txt`,e),await M(`${S}/max_bri.txt`,t),await M(`${S}/sleep_time.txt`,i),await M(`${S}/auto_bri_sleep.txt`,a),await M(`${S}/steps_num.txt`,o),await M(`${S}/log_max_size.txt`,s),await j(`rm -f "${T}"`);let c=await j(`cat "${w}"`);c.errno===0&&c.stdout.trim()?A(`配置已保存 (可能需要在下次调整时生效)`):A(`配置已保存 (服务未运行)`)}var F=!1,I=null;function L(){let e=document.getElementById(`btn-reset`);e.textContent=`恢复默认`,e.classList.remove(`btn-danger`),F=!1,I&&clearTimeout(I)}async function R(){let e=document.getElementById(`btn-reset`);if(!F){F=!0,e.textContent=`确认`,e.classList.add(`btn-danger`),I=setTimeout(L,5e3);return}A(`正在恢复默认配置...`),L();let[t,n,r,i,a,o]=await Promise.all([j(`cat "${C}/ui_max_bri.txt"`),j(`cat "${C}/max_bri.txt"`),j(`cat "${C}/sleep_time.txt"`),j(`cat "${C}/auto_bri_sleep.txt"`),j(`cat "${C}/steps_num.txt"`),j(`cat "${C}/log_max_size.txt"`)]);if(t.errno===0&&(document.getElementById(`input-ui-max-bri`).value=t.stdout.trim()),n.errno===0&&(document.getElementById(`input-max-bri`).value=n.stdout.trim()),r.errno===0){let e=r.stdout.trim(),t=document.getElementById(`input-sleep-mode`),n=document.getElementById(`sleep-time-expand`);if(e.includes(`-`)){t.checked=!0,n.classList.add(`sh
Line truncated
|
||||
+60
-25
@@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
|
||||
<title>LuminPro</title>
|
||||
<link rel="stylesheet" type="text/css" href="/internal/insets.css" />
|
||||
<script type="module" crossorigin src="/assets/index-GvCaVVmw.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-BjK9R0FR.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DpSbbGTK.css">
|
||||
</head>
|
||||
|
||||
@@ -27,6 +27,37 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 实时状态 -->
|
||||
<section class="card" id="status-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="activity"></i></span>
|
||||
<h2>实时状态</h2>
|
||||
<div class="header-actions">
|
||||
<button class="btn-text-s" id="btn-toggle-service">暂停</button>
|
||||
<button class="btn-text-s" id="btn-restart-service">重启</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<span class="status-label">当前亮度</span>
|
||||
<span class="status-value" id="status-current-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">系统最大亮度</span>
|
||||
<span class="status-value" id="status-sys-max-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">inotifyd PID</span>
|
||||
<span class="status-value" id="status-inotifyd-pid">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">休眠状态</span>
|
||||
<span class="status-value" id="status-sleep">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 配置卡片 -->
|
||||
<section class="card" id="config-section">
|
||||
<div class="card-header">
|
||||
@@ -134,34 +165,38 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 实时状态 -->
|
||||
<section class="card" id="status-section">
|
||||
<!-- 高级设置卡片 -->
|
||||
<section class="card" id="advanced-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="activity"></i></span>
|
||||
<h2>实时状态</h2>
|
||||
<div class="header-actions">
|
||||
<button class="btn-text-s" id="btn-toggle-service">暂停</button>
|
||||
<button class="btn-text-s" id="btn-restart-service">重启</button>
|
||||
<span class="card-icon"><i data-lucide="sliders"></i></span>
|
||||
<h2>高级设置</h2>
|
||||
</div>
|
||||
|
||||
<div class="config-group">
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">当前亮度节点</span>
|
||||
<span class="config-desc">修改需重启服务</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="text" id="input-now-bri-file" class="config-input config-input-wide" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">最大亮度节点</span>
|
||||
<span class="config-desc">修改需重启服务</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="text" id="input-sys-max-bri-file" class="config-input config-input-wide" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<span class="status-label">当前亮度</span>
|
||||
<span class="status-value" id="status-current-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">系统最大亮度</span>
|
||||
<span class="status-value" id="status-sys-max-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">inotifyd PID</span>
|
||||
<span class="status-value" id="status-inotifyd-pid">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">休眠状态</span>
|
||||
<span class="status-value" id="status-sleep">—</span>
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<button class="btn btn-primary" id="btn-save-advanced">
|
||||
<span class="btn-icon"><i data-lucide="save"></i></span> 保存设置
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in new issue
Block a user