chore: update

This commit is contained in:
YuleBest committed 2026-04-10 04:19:01 +08:00
1 parent 926c93e248
commit f9a060b7c9
2 files changed
+45 -25

No files matched your search

+25 -19
View File
@@ -1,11 +1,12 @@
//! lumipro: 带防抖的 inotify 监听工具 //! lumipro: 带防抖的 inotify 监听工具
//! //!
//! 用法: lumipro [--debounce <ms>] <handler> <path:events> [<path:events>...] //! 用法: lumipro [--debug] [--debounce <ms>] <handler> <path:events> [<path:events>...]
//! //!
//! 事件字母与 busybox inotifyd 完全兼容: //! 事件字母与 Android toybox inotifyd 完全兼容:
//! a=ACCESS c=CLOSE_WRITE e=CLOSE_NOWRITE w=OPEN //! a=ACCESS c=MODIFY e=ATTRIB w=CLOSE_WRITE
//! r=MOVED_FROM y=MOVED_TO n=CREATE d=DELETE //! 0=CLOSE_NOWRITE r=OPEN n=CREATE d=DELETE
//! D=DELETE_SELF M=MOVE_SELF u=MODIFY o=ATTRIB *=ALL //! D=DELETE_SELF M=MOVE_SELF m=MOVED_TO y=MOVED_FROM
//! u=UNMOUNT o=OVERFLOW x=IGNORED *=ALL
//! //!
//! 防抖机制: 在指定窗口期内多次触发时,只执行最后一次;handler 执行期间 //! 防抖机制: 在指定窗口期内多次触发时,只执行最后一次;handler 执行期间
//! 积压的事件(如亮度渐变写入)在 handler 返回后统一丢弃。 //! 积压的事件(如亮度渐变写入)在 handler 返回后统一丢弃。
@@ -25,18 +26,20 @@ mod linux {
for c in letters.chars() { for c in letters.chars() {
mask |= match c { mask |= match c {
'a' => WatchMask::ACCESS, 'a' => WatchMask::ACCESS,
'c' => WatchMask::CLOSE_WRITE, 'c' => WatchMask::MODIFY, // toybox: modified
'e' => WatchMask::CLOSE_NOWRITE, 'e' => WatchMask::ATTRIB, // toybox: metadata change
'w' => WatchMask::OPEN, 'w' => WatchMask::CLOSE_WRITE, // toybox: closed (writable)
'r' => WatchMask::MOVED_FROM, '0' => WatchMask::CLOSE_NOWRITE, // toybox: closed (unwritable)
'y' => WatchMask::MOVED_TO, 'r' => WatchMask::OPEN, // toybox: opened
'n' => WatchMask::CREATE, 'n' => WatchMask::CREATE,
'd' => WatchMask::DELETE, 'd' => WatchMask::DELETE,
'D' => WatchMask::DELETE_SELF, 'D' => WatchMask::DELETE_SELF,
'M' => WatchMask::MOVE_SELF, 'M' => WatchMask::MOVE_SELF,
'u' => WatchMask::MODIFY, 'm' => WatchMask::MOVED_TO, // toybox: moved in
'o' => WatchMask::ATTRIB, 'y' => WatchMask::MOVED_FROM, // toybox: moved out
'u' => WatchMask::UNMOUNT, // toybox: unmounted
'*' => WatchMask::ALL_EVENTS, '*' => WatchMask::ALL_EVENTS,
// 'o'=overflow 'x'=ignored 为内核产生,不设置 watch mask
_ => WatchMask::empty(), _ => WatchMask::empty(),
}; };
} }
@@ -46,17 +49,20 @@ mod linux {
fn mask_to_letters(mask: EventMask) -> String { fn mask_to_letters(mask: EventMask) -> String {
let mut s = String::new(); let mut s = String::new();
if mask.contains(EventMask::ACCESS) { s.push('a'); } if mask.contains(EventMask::ACCESS) { s.push('a'); }
if mask.contains(EventMask::CLOSE_WRITE) { s.push('c'); } if mask.contains(EventMask::MODIFY) { s.push('c'); }
if mask.contains(EventMask::CLOSE_NOWRITE) { s.push('e'); } if mask.contains(EventMask::ATTRIB) { s.push('e'); }
if mask.contains(EventMask::OPEN) { s.push('w'); } if mask.contains(EventMask::CLOSE_WRITE) { s.push('w'); }
if mask.contains(EventMask::MOVED_FROM) { s.push('r'); } if mask.contains(EventMask::CLOSE_NOWRITE) { s.push('0'); }
if mask.contains(EventMask::MOVED_TO) { s.push('y'); } if mask.contains(EventMask::OPEN) { s.push('r'); }
if mask.contains(EventMask::MOVED_FROM) { s.push('y'); }
if mask.contains(EventMask::MOVED_TO) { s.push('m'); }
if mask.contains(EventMask::CREATE) { s.push('n'); } if mask.contains(EventMask::CREATE) { s.push('n'); }
if mask.contains(EventMask::DELETE) { s.push('d'); } if mask.contains(EventMask::DELETE) { s.push('d'); }
if mask.contains(EventMask::DELETE_SELF) { s.push('D'); } if mask.contains(EventMask::DELETE_SELF) { s.push('D'); }
if mask.contains(EventMask::MOVE_SELF) { s.push('M'); } if mask.contains(EventMask::MOVE_SELF) { s.push('M'); }
if mask.contains(EventMask::MODIFY) { s.push('u'); } if mask.contains(EventMask::UNMOUNT) { s.push('u'); }
if mask.contains(EventMask::ATTRIB) { s.push('o'); } if mask.contains(EventMask::Q_OVERFLOW) { s.push('o'); }
if mask.contains(EventMask::IGNORED) { s.push('x'); }
if s.is_empty() { s.push('?'); } if s.is_empty() { s.push('?'); }
s s
} }
+20 -6
View File
@@ -42,10 +42,24 @@ function setTheme(v) {
} }
async function viewInotifyHelp() { async function viewInotifyHelp() {
showToast('获取中...') const msg = `支持的事件字母 (toybox inotifyd 兼容):
const res = await runCmd('inotifyd --help') a = accessed 读取
const out = (res.stderr || '') + (res.stdout || '') c = modified 内容修改 (亮度节点推荐用此)
alert(out.trim() || '无法获取帮助信息') e = metadata change 属性变更
w = closed (writable) 写入后关闭
0 = closed (unwritable) 查看后关闭
r = opened 打开
n = created 创建
d = deleted 删除(目录内)
D = deleted (self) 自身被删除
M = moved (self) 自身被移动
m = moved in 移入目录
y = moved out 移出目录
u = unmounted 挂载卷卸载
* = all events
提示: sysfs 亮度节点使用 c (MODIFY),这也是默认值`
alert(msg)
} }
function handleSaveWebUI() { function handleSaveWebUI() {
@@ -224,8 +238,8 @@ function handleSaveWebUI() {
<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">lumipro 监听事件</span>
<span class="config-desc">默认 c。修改需重启服务</span> <span class="config-desc">默认 c(sysfs MODIFY)。修改需重启服务</span>
<span class="config-desc" style="color: var(--color-warning)" <span class="config-desc" style="color: var(--color-warning)"
>修改为 c 以外时建议关闭自动刷新</span >修改为 c 以外时建议关闭自动刷新</span
> >