Files
aglab.dotfiles/bin/startb
SilverAg.L a1a0c2bdb6 重写 startb;补点中文注释;删减多余的定时模板
为啥又中文了?英文太长,中英夹杂键起来别扭。

不会真有人用我原始人般的配置吧?
2026-03-24 03:08:10 +08:00

46 lines
1.4 KiB
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.
#!/bin/bash
# like `start /b` in Windows CMD.
# PATH 不完整问题:
# 根据 niri 启动方式的不同niri 读到的环境变量可能也不一样。
# - tty 进终端再 niri-session 拉起来大概是最完整的。毕竟已经加载 .xxxrc 了嘛。
# - 而像我这样用 sddm 进的 niri由于直接从 systemd-user 启动,中间也没有任何机会更新 PATH相比就最麻烦了。
# 根据谷鸽 AI 的回答,我这种情况只能在 ~/.config/environment.d/ 里静态补上环境变量。
# 之前不懂的时候用的是如下的奇技淫巧:
# PATH=$(zsh -c -i 'echo $PATH')
# export PATH
# https://vescrity.github.io/post/systemd-desktop-suspend/
#systemd-run --user --scope --slice=YukiLauncher.slice --unit="$1-$$".scope /bin/sh -c '"$@"' _ "$@"
if [ $# -lt 1 ]; then
echo "Usage: daemon-run COMMAND [ARGS...]"
exit 1
fi
CMD_NAME="${1##*/}"
UNIT_NAME="${CMD_NAME}-$(date +%s%N)"
ENV_ARGS=(
--setenv=PATH="$PATH"
--setenv=PWD="$PWD"
)
[ -n "$NVM_DIR" ] && ENV_ARGS+=(--setenv=NVM_DIR="$NVM_DIR")
[ -n "$NVM_BIN" ] && ENV_ARGS+=(--setenv=NVM_BIN="$NVM_BIN")
systemd-run --user \
"${ENV_ARGS[@]}" \
--working-directory="$PWD" \
--slice=StartProcess.slice \
--unit="$UNIT_NAME" \
--remain-after-exit \
--collect \
-- "$@"
if [ $? -eq 0 ]; then
echo "📜 Logs : journalctl --user -u $UNIT_NAME -f"
echo "✅ Manage : systemctl --user stop $UNIT_NAME"
fi