#!/bin/bash

set -e

echo "Pobieranie fastfetch..."
TEMP_DEB="$(mktemp --suffix=.deb)"
wget -O "$TEMP_DEB" https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-linux-amd64.deb

echo "Instalacja pakietu..."
sudo apt update
sudo apt install -y "$TEMP_DEB"

rm "$TEMP_DEB"

echo ""
read -p "Czy chcesz dodać alias 'ff' do pliku .bashrc? (t/n): " answer

if [[ "$answer" =~ ^[tTyY]$ ]]; then
    if grep -q "alias ff='fastfetch'" "$HOME/.bashrc"; then
        echo "Alias 'ff' już istnieje w .bashrc."
    else
        echo "" >> "$HOME/.bashrc"
        echo "# Alias dla fastfetch" >> "$HOME/.bashrc"
        echo "alias ff='fastfetch'" >> "$HOME/.bashrc"
        echo "Dodano alias 'ff'. Aby zadziałał, wpisz: source ~/.bashrc lub zrestartuj terminal."
    fi
else
    echo "Pominięto tworzenie aliasu."
fi

echo ""
echo "Uruchamianie fastfetch..."
fastfetch
