2024-09-16 02:11:48 +01:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
|
|
. ../common-script.sh
|
|
|
|
|
2024-09-17 03:10:02 +01:00
|
|
|
installFastfetch() {
|
2024-09-16 02:11:48 +01:00
|
|
|
if ! command_exists fastfetch; then
|
2024-09-20 15:27:31 +01:00
|
|
|
printf "%b\n" "${YELLOW}Installing Fastfetch...${RC}"
|
2024-09-17 13:23:23 +01:00
|
|
|
case "$PACKAGER" in
|
2025-01-20 10:09:39 +00:00
|
|
|
pacman)
|
|
|
|
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm fastfetch
|
|
|
|
;;
|
|
|
|
apt-get | nala)
|
|
|
|
curl -sSLo /tmp/fastfetch.deb https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-linux-amd64.deb
|
|
|
|
"$ESCALATION_TOOL" "$PACKAGER" install -y /tmp/fastfetch.deb
|
|
|
|
rm /tmp/fastfetch.deb
|
|
|
|
;;
|
|
|
|
apk)
|
|
|
|
"$ESCALATION_TOOL" "$PACKAGER" add fastfetch
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
"$ESCALATION_TOOL" "$PACKAGER" install -y fastfetch
|
|
|
|
;;
|
2024-09-16 02:11:48 +01:00
|
|
|
esac
|
|
|
|
else
|
2024-09-17 03:44:20 +01:00
|
|
|
printf "%b\n" "${GREEN}Fastfetch is already installed.${RC}"
|
2024-09-16 02:11:48 +01:00
|
|
|
fi
|
2024-09-16 03:32:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setupFastfetchConfig() {
|
2024-09-17 03:44:20 +01:00
|
|
|
printf "%b\n" "${YELLOW}Copying Fastfetch config files...${RC}"
|
2024-09-16 02:11:48 +01:00
|
|
|
if [ -d "${HOME}/.config/fastfetch" ] && [ ! -d "${HOME}/.config/fastfetch-bak" ]; then
|
|
|
|
cp -r "${HOME}/.config/fastfetch" "${HOME}/.config/fastfetch-bak"
|
|
|
|
fi
|
|
|
|
mkdir -p "${HOME}/.config/fastfetch/"
|
|
|
|
curl -sSLo "${HOME}/.config/fastfetch/config.jsonc" https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/config.jsonc
|
|
|
|
}
|
|
|
|
|
2025-01-13 20:37:37 +00:00
|
|
|
setupFastfetchShell() {
|
|
|
|
printf "%b\n" "${YELLOW}Configuring shell integration...${RC}"
|
2025-01-20 10:09:39 +00:00
|
|
|
|
2025-01-13 20:37:37 +00:00
|
|
|
# Get current shell and RC file path
|
|
|
|
current_shell=$(basename "$SHELL")
|
|
|
|
rc_file=""
|
2025-01-20 10:09:39 +00:00
|
|
|
|
2025-01-13 20:37:37 +00:00
|
|
|
case "$current_shell" in
|
2025-01-20 10:09:39 +00:00
|
|
|
"bash")
|
|
|
|
rc_file="$HOME/.bashrc"
|
|
|
|
;;
|
|
|
|
"zsh")
|
|
|
|
rc_file="$HOME/.zshrc"
|
|
|
|
;;
|
|
|
|
*)
|
2025-01-22 08:49:49 +00:00
|
|
|
printf "%b\n" "${RED}$current_shell is not supported. Update your shell configuration manually.${RC}"
|
2025-01-20 10:09:39 +00:00
|
|
|
;;
|
2025-01-13 20:37:37 +00:00
|
|
|
esac
|
2025-01-20 10:09:39 +00:00
|
|
|
|
2025-01-22 08:49:57 +00:00
|
|
|
if [ ! -f "$rc_file" ]; then
|
|
|
|
printf "%b\n" "${RED}Shell config file $rc_file not found${RC}"
|
2025-01-13 20:37:37 +00:00
|
|
|
else
|
2025-01-20 10:09:39 +00:00
|
|
|
if grep -q "fastfetch" "$rc_file"; then
|
|
|
|
printf "%b\n" "${YELLOW}Fastfetch is already configured in $rc_file${RC}"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
# Ask for confirmation
|
|
|
|
printf "%b" "${GREEN}Would you like to add fastfetch to $rc_file? [y/N] ${RC}"
|
|
|
|
read -r response
|
|
|
|
|
|
|
|
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
|
|
|
|
printf "\n# Run fastfetch on terminal start\nfastfetch\n" >>"$rc_file"
|
|
|
|
printf "%b\n" "${GREEN}Added fastfetch to $rc_file${RC}"
|
|
|
|
else
|
|
|
|
printf "%b\n" "${YELLOW}Skipped adding fastfetch to shell config${RC}"
|
|
|
|
fi
|
|
|
|
fi
|
2025-01-13 20:37:37 +00:00
|
|
|
fi
|
2025-01-20 10:09:39 +00:00
|
|
|
|
2025-01-13 20:37:37 +00:00
|
|
|
}
|
|
|
|
|
2024-09-16 02:11:48 +01:00
|
|
|
checkEnv
|
|
|
|
checkEscalationTool
|
2024-09-17 03:10:02 +01:00
|
|
|
installFastfetch
|
2025-01-13 20:37:37 +00:00
|
|
|
setupFastfetchConfig
|
2025-01-20 10:09:39 +00:00
|
|
|
setupFastfetchShell
|