From 67bbcc623d36aa9b1c97280848e0f6f4b5ce8118 Mon Sep 17 00:00:00 2001 From: jaberjaber23 Date: Fri, 1 May 2026 13:18:19 +0300 Subject: [PATCH] cachyos build --- docs/troubleshooting.md | 15 +++++++ scripts/install.sh | 86 +++++++++++++++++++++++++++-------------- 2 files changed, 73 insertions(+), 28 deletions(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 4eb76a45..c5ee68fe 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -88,6 +88,21 @@ export PATH="$HOME/.cargo/bin:$PATH" # Add to ~/.bashrc or ~/.zshrc to persist ``` +### Black screen on login after install (Arch / CachyOS / fish users) + +**Cause**: Older OpenFang installers (`/dev/null | cut -d: -f7) fi - SHELL_RC="" + # Fish shell: write to ~/.config/fish/conf.d/openfang.fish (drop-in dir). + # This keeps the user's config.fish completely untouched, so a broken + # PATH entry can never wedge the user's main shell config — critical + # on Arch/CachyOS where the desktop session sources fish on login. + USE_FISH_DROPIN=0 case "$USER_SHELL" in - */zsh) SHELL_RC="$HOME/.zshrc" ;; - */bash) SHELL_RC="$HOME/.bashrc" ;; - */fish) SHELL_RC="$HOME/.config/fish/config.fish" ;; + */fish) USE_FISH_DROPIN=1 ;; esac - # Also check for config files if shell detection failed. - # Check bash/zsh first (more common defaults), fish last — avoids - # writing to config.fish for users who merely have Fish installed. - if [ -z "$SHELL_RC" ]; then - if [ -f "$HOME/.bashrc" ]; then - SHELL_RC="$HOME/.bashrc" - elif [ -f "$HOME/.zshrc" ]; then - SHELL_RC="$HOME/.zshrc" - elif [ -f "$HOME/.config/fish/config.fish" ]; then - SHELL_RC="$HOME/.config/fish/config.fish" - fi + # If $USER_SHELL didn't match fish but config.fish exists AND no other + # rc files exist, the user is likely a fish user — use the drop-in too. + if [ "$USE_FISH_DROPIN" -eq 0 ] \ + && [ -f "$HOME/.config/fish/config.fish" ] \ + && [ ! -f "$HOME/.bashrc" ] \ + && [ ! -f "$HOME/.zshrc" ]; then + USE_FISH_DROPIN=1 fi - if [ -n "$SHELL_RC" ] && ! grep -q "openfang" "$SHELL_RC" 2>/dev/null; then - # Determine syntax from the TARGET FILE, not $USER_SHELL — this - # prevents Bash syntax from ever being written to config.fish even - # when shell detection mis-identifies the user's shell. - case "$SHELL_RC" in - */config.fish) - mkdir -p "$(dirname "$SHELL_RC")" - echo "fish_add_path \"$INSTALL_DIR\"" >> "$SHELL_RC" - ;; - *) - echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$SHELL_RC" - ;; + if [ "$USE_FISH_DROPIN" -eq 1 ]; then + FISH_CONF_DIR="$HOME/.config/fish/conf.d" + FISH_DROPIN="$FISH_CONF_DIR/openfang.fish" + mkdir -p "$FISH_CONF_DIR" + if [ ! -f "$FISH_DROPIN" ]; then + # Guarded with `test -d` so a missing/broken install dir never + # breaks fish startup (which would black-screen Arch/CachyOS + # desktop sessions that source fish at login). + cat > "$FISH_DROPIN" </dev/null; then + # Remove any line containing .openfang/bin (covers both bash + # `export PATH=` syntax and old fish `set -gx PATH` lines). + TMPFILE=$(mktemp) + grep -v "openfang/bin" "$OLD_FISH_RC" > "$TMPFILE" || true + mv "$TMPFILE" "$OLD_FISH_RC" + echo " Cleaned legacy openfang PATH entry from $OLD_FISH_RC" + fi + else + SHELL_RC="" + case "$USER_SHELL" in + */zsh) SHELL_RC="$HOME/.zshrc" ;; + */bash) SHELL_RC="$HOME/.bashrc" ;; esac - echo " Added $INSTALL_DIR to PATH in $SHELL_RC" + # Fall back to existing rc files when shell detection failed. + if [ -z "$SHELL_RC" ]; then + if [ -f "$HOME/.bashrc" ]; then + SHELL_RC="$HOME/.bashrc" + elif [ -f "$HOME/.zshrc" ]; then + SHELL_RC="$HOME/.zshrc" + fi + fi + + if [ -n "$SHELL_RC" ] && ! grep -q "openfang" "$SHELL_RC" 2>/dev/null; then + echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$SHELL_RC" + echo " Added $INSTALL_DIR to PATH in $SHELL_RC" + fi fi # Verify installation