diff --git a/README.md b/README.md index 60b9187..8264cbd 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,10 @@ bash /tmp/install-niri.sh --config-only - Rust 工具链隔离在 `~/.local/share/niri-beyond-glass` - 配置安装后使用 `niri validate` 校验 -备份位于: +首次安装前的原配置和更新快照位于: ```text +~/.local/state/niri-beyond-glass/original/ ~/.local/state/niri-beyond-glass/backups/ ``` diff --git a/config/niri/config.kdl b/config/niri/config.kdl index 3bf38ed..05aec85 100644 --- a/config/niri/config.kdl +++ b/config/niri/config.kdl @@ -27,8 +27,6 @@ environment { spawn-at-startup "xwayland-satellite" spawn-at-startup "sh" "-lc" "$HOME/.local/bin/niri-beyond-wallpaper" -spawn-at-startup "waybar" -spawn-at-startup "mako" spawn-at-startup "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1" spawn-at-startup "swayidle" "-w" "timeout" "600" "swaylock -f" "timeout" "660" "niri msg action power-off-monitors" "resume" "niri msg action power-on-monitors" "before-sleep" "swaylock -f" diff --git a/config/waybar/config.jsonc b/config/waybar/config.jsonc index 6851535..722dbc0 100644 --- a/config/waybar/config.jsonc +++ b/config/waybar/config.jsonc @@ -8,7 +8,7 @@ "margin-right": 8, "modules-left": ["custom/launcher"], "modules-center": [], - "modules-right": ["tray", "network", "pulseaudio", "battery", "clock", "custom/lock", "custom/power"], + "modules-right": ["tray", "network", "pulseaudio", "battery", "custom/lock", "custom/power", "clock"], "custom/launcher": { "format": " \uf141 ", "tooltip": false, diff --git a/install.sh b/install.sh index 0127c65..8fe3454 100755 --- a/install.sh +++ b/install.sh @@ -46,7 +46,9 @@ run() { } cleanup() { - [[ -n "$tmp_dir" && -d "$tmp_dir" ]] && rm -rf "$tmp_dir" + if [[ -n "$tmp_dir" && -d "$tmp_dir" ]]; then + rm -rf "$tmp_dir" + fi } trap cleanup EXIT @@ -117,7 +119,7 @@ install_packages() { run sudo apt-get update run sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y \ build-essential clang git curl ca-certificates pkg-config \ - meson ninja-build cmake \ + meson ninja-build cmake hwdata \ libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev \ libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev \ libseat-dev libpipewire-0.3-dev libpango1.0-dev \ @@ -142,12 +144,20 @@ install_rust() { printf '+ curl https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain %q\n' "$RUST_TOOLCHAIN" return fi - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | - sh -s -- -y --no-modify-path --profile minimal --default-toolchain "$RUST_TOOLCHAIN" - else - run "$CARGO_HOME/bin/rustup" toolchain install "$RUST_TOOLCHAIN" --profile minimal - run "$CARGO_HOME/bin/rustup" default "$RUST_TOOLCHAIN" + local rustup_installer + rustup_installer="$(mktemp)" + curl --proto '=https' --tlsv1.2 -fsSL --retry 5 --retry-all-errors \ + https://sh.rustup.rs -o "$rustup_installer" + RUSTUP_MAX_RETRIES=5 sh "$rustup_installer" -y --no-modify-path \ + --profile minimal --default-toolchain "$RUST_TOOLCHAIN" + rm -f "$rustup_installer" + elif ! "$CARGO_HOME/bin/rustup" run "$RUST_TOOLCHAIN" rustc --version >/dev/null 2>&1; then + RUSTUP_MAX_RETRIES=5 run "$CARGO_HOME/bin/rustup" toolchain install \ + "$RUST_TOOLCHAIN" --profile minimal fi + + run "$CARGO_HOME/bin/rustup" set auto-self-update disable + run "$CARGO_HOME/bin/rustup" default "$RUST_TOOLCHAIN" } version_ge() { @@ -229,6 +239,7 @@ backup_and_install_config() { local stamp stamp="$(date +%Y%m%d-%H%M%S)" local backup="$state_home/$PROJECT/backups/$stamp/config" + local original="$state_home/$PROJECT/original" local names=(niri waybar fuzzel mako swaylock niri-beyond-glass) log "备份并安装用户配置" @@ -240,6 +251,16 @@ backup_and_install_config() { fi done + if [[ ! -e "$original/.captured" ]]; then + run mkdir -p "$original/config" + for name in "${names[@]}"; do + if [[ -e "$config_home/$name" ]]; then + run cp -a "$config_home/$name" "$original/config/$name" + fi + done + run touch "$original/.captured" + fi + run mkdir -p \ "$config_home/niri" \ "$config_home/waybar" \ diff --git a/uninstall.sh b/uninstall.sh index bda260c..c06ce6c 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -4,9 +4,12 @@ set -euo pipefail config_home="${XDG_CONFIG_HOME:-$HOME/.config}" state_home="${XDG_STATE_HOME:-$HOME/.local/state}" backup_root="$state_home/niri-beyond-glass/backups" +original_root="$state_home/niri-beyond-glass/original" latest="" -if [[ -d "$backup_root" ]]; then +if [[ -e "$original_root/.captured" ]]; then + latest="$original_root" +elif [[ -d "$backup_root" ]]; then latest="$(find "$backup_root" -mindepth 1 -maxdepth 1 -type d -printf '%p\n' | sort | tail -n 1)" fi