Files
kindle-calendar/dash/src/debug-off.sh
2026-03-17 10:37:27 +08:00

45 lines
1003 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env sh
# 持久关闭调试模式:修改 env.sh恢复正常的省电挂起行为。
set -eu
DIR="$(dirname "$0")"
ENV_FILE="$DIR/local/env.sh"
TMP_FILE="$DIR/local/env.sh.tmp"
if [ ! -f "$ENV_FILE" ]; then
echo "未找到配置文件:$ENV_FILE"
exit 1
fi
# 只替换目标配置,避免重复追加同一环境变量。
awk '
BEGIN {
updated = 0
}
/^export DISABLE_SYSTEM_SUSPEND=/ {
print "export DISABLE_SYSTEM_SUSPEND=false"
updated = 1
next
}
{
print
}
END {
if (!updated) {
print "export DISABLE_SYSTEM_SUSPEND=false"
}
}
' "$ENV_FILE" > "$TMP_FILE"
mv "$TMP_FILE" "$ENV_FILE"
# 已运行的 dashboard 进程不会重新读取 env.sh切换后先停掉它
# 然后立刻拉起新的 dashboard避免用户还要再次手动启动。
pkill -f "$DIR/dash.sh" 2>/dev/null || true
pkill -f "$DIR/local/theme-menu-service.sh" 2>/dev/null || true
sleep 1
"$DIR/start.sh"
echo "已关闭 Dashboard 调试模式,并自动重启 Kindle Dashboard。"