mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
chore: update
This commit is contained in:
1 parent
0b0ad4acd6
commit
926c93e248
4 files changed
+53
-7
No files matched your search
+32
-6
@@ -84,10 +84,18 @@ mod linux {
|
|||||||
let mut idx = 0;
|
let mut idx = 0;
|
||||||
|
|
||||||
let mut debounce_ms: u64 = 300;
|
let mut debounce_ms: u64 = 300;
|
||||||
if args.get(idx).map(String::as_str) == Some("--debounce") {
|
let mut debug = false;
|
||||||
idx += 1;
|
|
||||||
debounce_ms = args.get(idx).and_then(|s| s.parse().ok()).unwrap_or(300);
|
loop {
|
||||||
idx += 1;
|
match args.get(idx).map(String::as_str) {
|
||||||
|
Some("--debug") => { debug = true; idx += 1; }
|
||||||
|
Some("--debounce") => {
|
||||||
|
idx += 1;
|
||||||
|
debounce_ms = args.get(idx).and_then(|s| s.parse().ok()).unwrap_or(300);
|
||||||
|
idx += 1;
|
||||||
|
}
|
||||||
|
_ => break,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let handler = match args.get(idx) {
|
let handler = match args.get(idx) {
|
||||||
@@ -124,6 +132,9 @@ mod linux {
|
|||||||
let mask = letters_to_mask(letters);
|
let mask = letters_to_mask(letters);
|
||||||
match inotify.watches().add(&path, mask) {
|
match inotify.watches().add(&path, mask) {
|
||||||
Ok(wd) => {
|
Ok(wd) => {
|
||||||
|
if debug {
|
||||||
|
eprintln!("[lumipro] watching: {} events: {}", path_str, letters);
|
||||||
|
}
|
||||||
watches.insert(wd, (path, letters.to_string()));
|
watches.insert(wd, (path, letters.to_string()));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@@ -133,6 +144,10 @@ mod linux {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if debug {
|
||||||
|
eprintln!("[lumipro] debounce={}ms handler={}", debounce_ms, handler);
|
||||||
|
}
|
||||||
|
|
||||||
let debounce = Duration::from_millis(debounce_ms);
|
let debounce = Duration::from_millis(debounce_ms);
|
||||||
let mut pending: Option<Pending> = None;
|
let mut pending: Option<Pending> = None;
|
||||||
let mut buffer = [0u8; 4096];
|
let mut buffer = [0u8; 4096];
|
||||||
@@ -161,9 +176,13 @@ mod linux {
|
|||||||
Ok(events) => {
|
Ok(events) => {
|
||||||
for event in events {
|
for event in events {
|
||||||
if let Some((path, _)) = watches.get(&event.wd) {
|
if let Some((path, _)) = watches.get(&event.wd) {
|
||||||
|
let letters = mask_to_letters(event.mask);
|
||||||
|
if debug {
|
||||||
|
eprintln!("[lumipro] event: {} path: {}", letters, path.display());
|
||||||
|
}
|
||||||
pending = Some(Pending {
|
pending = Some(Pending {
|
||||||
triggered_at: Instant::now(),
|
triggered_at: Instant::now(),
|
||||||
event_letters: mask_to_letters(event.mask),
|
event_letters: letters,
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -174,20 +193,27 @@ mod linux {
|
|||||||
}
|
}
|
||||||
} else if let Some(p) = pending.take() {
|
} else if let Some(p) = pending.take() {
|
||||||
// ── 3. 防抖窗口结束:同步执行 handler ───────────────────────
|
// ── 3. 防抖窗口结束:同步执行 handler ───────────────────────
|
||||||
|
if debug {
|
||||||
|
eprintln!("[lumipro] debounce fired → handler: {} {}", p.event_letters, p.path.display());
|
||||||
|
}
|
||||||
let _ = Command::new(&handler)
|
let _ = Command::new(&handler)
|
||||||
.arg(&p.event_letters)
|
.arg(&p.event_letters)
|
||||||
.arg(&p.path)
|
.arg(&p.path)
|
||||||
.status();
|
.status();
|
||||||
|
|
||||||
// ── 4. 丢弃 handler 执行期间(亮度渐变写入)积压的全部事件 ─
|
// ── 4. 丢弃 handler 执行期间(亮度渐变写入)积压的全部事件 ─
|
||||||
|
let mut drained = 0usize;
|
||||||
loop {
|
loop {
|
||||||
match inotify.read_events(&mut buffer) {
|
match inotify.read_events(&mut buffer) {
|
||||||
Ok(events) => {
|
Ok(events) => {
|
||||||
for _ in events {}
|
for _ in events { drained += 1; }
|
||||||
}
|
}
|
||||||
Err(_) => break, // WouldBlock:积压已清空
|
Err(_) => break, // WouldBlock:积压已清空
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if debug && drained > 0 {
|
||||||
|
eprintln!("[lumipro] drain: discarded {} event(s)", drained);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -77,11 +77,16 @@ while true; do
|
|||||||
_log "正在启动 lumipro 监听" "INFO"
|
_log "正在启动 lumipro 监听" "INFO"
|
||||||
now_bri_file="${current_config%|*}"
|
now_bri_file="${current_config%|*}"
|
||||||
inotify_events="${current_config#*|}"
|
inotify_events="${current_config#*|}"
|
||||||
|
debug_mode="$(get_cfg debug_mode "0")"
|
||||||
|
|
||||||
# 缓存当前监听路径(供参考)
|
# 缓存当前监听路径(供参考)
|
||||||
echo -n "$now_bri_file" >"$MODDIR/config/.cached_path"
|
echo -n "$now_bri_file" >"$MODDIR/config/.cached_path"
|
||||||
|
|
||||||
"$MODDIR/bin/lumipro" "$MODDIR/script/up.sh" "$now_bri_file:$inotify_events" >>"$log_file" 2>&1 &
|
if [ "$debug_mode" = "1" ]; then
|
||||||
|
"$MODDIR/bin/lumipro" --debug "$MODDIR/script/up.sh" "$now_bri_file:$inotify_events" >>"$log_file" 2>&1 &
|
||||||
|
else
|
||||||
|
"$MODDIR/bin/lumipro" "$MODDIR/script/up.sh" "$now_bri_file:$inotify_events" >>"$log_file" 2>&1 &
|
||||||
|
fi
|
||||||
inotify_pid=$!
|
inotify_pid=$!
|
||||||
echo "$inotify_pid" >"$pid_file"
|
echo "$inotify_pid" >"$pid_file"
|
||||||
_log "lumipro 已启动 (PID: $inotify_pid), 监听: $now_bri_file, 事件: $inotify_events" "SUCCESS"
|
_log "lumipro 已启动 (PID: $inotify_pid), 监听: $now_bri_file, 事件: $inotify_events" "SUCCESS"
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export function useConfig() {
|
|||||||
const nowBriFile = ref(DEFAULT_NOW_BRI_FILE)
|
const nowBriFile = ref(DEFAULT_NOW_BRI_FILE)
|
||||||
const sysMaxBriFile = ref(DEFAULT_SYS_MAX_BRI_FILE)
|
const sysMaxBriFile = ref(DEFAULT_SYS_MAX_BRI_FILE)
|
||||||
const inotifyEvents = ref('c')
|
const inotifyEvents = ref('c')
|
||||||
|
const debugMode = ref(false)
|
||||||
|
|
||||||
// Web UI 配置 (localStorage 持久化)
|
// Web UI 配置 (localStorage 持久化)
|
||||||
const autoRefresh = ref(localStorage.getItem('autoRefresh') !== 'false')
|
const autoRefresh = ref(localStorage.getItem('autoRefresh') !== 'false')
|
||||||
@@ -55,6 +56,7 @@ export function useConfig() {
|
|||||||
nowBriFile.value = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE
|
nowBriFile.value = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE
|
||||||
sysMaxBriFile.value = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE
|
sysMaxBriFile.value = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE
|
||||||
inotifyEvents.value = cfg.inotify_events || 'c'
|
inotifyEvents.value = cfg.inotify_events || 'c'
|
||||||
|
debugMode.value = cfg.debug_mode === 1
|
||||||
|
|
||||||
const st = cfg.sleep_time || ''
|
const st = cfg.sleep_time || ''
|
||||||
if (st && st.includes('-')) {
|
if (st && st.includes('-')) {
|
||||||
@@ -112,6 +114,7 @@ export function useConfig() {
|
|||||||
now_bri_file: nowBriFile.value || DEFAULT_NOW_BRI_FILE,
|
now_bri_file: nowBriFile.value || DEFAULT_NOW_BRI_FILE,
|
||||||
max_bri_file: sysMaxBriFile.value || DEFAULT_SYS_MAX_BRI_FILE,
|
max_bri_file: sysMaxBriFile.value || DEFAULT_SYS_MAX_BRI_FILE,
|
||||||
inotify_events: inotifyEvents.value || 'c',
|
inotify_events: inotifyEvents.value || 'c',
|
||||||
|
debug_mode: debugMode.value ? 1 : 0,
|
||||||
})
|
})
|
||||||
onPathsChanged?.()
|
onPathsChanged?.()
|
||||||
toast('高级设置已保存,需重启服务生效')
|
toast('高级设置已保存,需重启服务生效')
|
||||||
@@ -207,6 +210,7 @@ export function useConfig() {
|
|||||||
nowBriFile,
|
nowBriFile,
|
||||||
sysMaxBriFile,
|
sysMaxBriFile,
|
||||||
inotifyEvents,
|
inotifyEvents,
|
||||||
|
debugMode,
|
||||||
autoRefresh,
|
autoRefresh,
|
||||||
statusRefreshInterval,
|
statusRefreshInterval,
|
||||||
uiZoom,
|
uiZoom,
|
||||||
|
|||||||
@@ -211,6 +211,17 @@ function handleSaveWebUI() {
|
|||||||
<div class="config-group">
|
<div class="config-group">
|
||||||
<h3 class="group-title"><Settings :size="16" /> 运行环境</h3>
|
<h3 class="group-title"><Settings :size="16" /> 运行环境</h3>
|
||||||
|
|
||||||
|
<div class="config-item">
|
||||||
|
<div class="config-label">
|
||||||
|
<span class="config-name">调试模式</span>
|
||||||
|
<span class="config-desc">将每个 inotify 事件及防抖触发信息写入日志</span>
|
||||||
|
<span class="config-desc" style="color: var(--color-warning)"
|
||||||
|
>开启后需重启服务,日志量增大。诊断完成后请关闭</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<Switch v-model="config.debugMode.value" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="config-item">
|
<div class="config-item">
|
||||||
<div class="config-label">
|
<div class="config-label">
|
||||||
<span class="config-name">inotifyd 监听事件</span>
|
<span class="config-name">inotifyd 监听事件</span>
|
||||||
|
|||||||
Reference in new issue
Block a user