#!/bin/bash detect_dual_boot() { if [[ $EUID -eq 0 ]] && [[ -x /usr/bin/os-prober ]]; then local OSPROBER_OUT="$(os-prober)" || { DUALBOOT="Os-prober error"; exit; } echo $OSPROBER_OUT | grep -q "Windows Boot Manager" &> /dev/null && DUALBOOT="Yes" || DUALBOOT="No/Undetected" elif [[ -x /usr/bin/efibootmgr ]] && [ -d /boot/efi ]; then local EFIBOOTMGR_OUT="$(efibootmgr)" || { DUALBOOT="Efibootmgr error"; exit; } echo $EFIBOOTMGR_OUT | grep -q "Windows Boot Manager" &> /dev/null && DUALBOOT="Probably (Run as root to verify)" || DUALBOOT="No/Undetected" elif [[ -x /usr/bin/os-prober ]]; then DUALBOOT="" else DUALBOOT="No detection tool installed" fi } detect_snapshots() { if [ -d /.snapshots ] || pacman -Qq snapper-support &> /dev/null; then printf "snapper " elif [ -d /run/timeshift ] || pacman -Qq timeshift-support &> /dev/null; then printf "timeshift " elif pacman -Qq snapper &> /dev/null; then printf "snapper(custom) " elif pacman -Qq timeshift &> /dev/null; then printf "timeshift(custom) " fi } generate_relevant_software() { local RELEVANT=() local packages packages="$(pacman -Qq garuda-dracut-support mkinitcpio dracut nvidia-dkms 2> /dev/null | xargs || true)" systemctl is-enabled tlp &> /dev/null && RELEVANT+=("tlp") systemctl is-active NetworkManager &> /dev/null && RELEVANT+=("NetworkManager") systemctl is-active connman &> /dev/null && RELEVANT+=("connman") if [[ "$packages" =~ (^| )garuda-dracut-support($| ) ]]; then RELEVANT+=("dracut") elif [[ "$packages" =~ (^| )dracut($| ) ]]; then RELEVANT+=("dracut(custom)") fi [[ "$packages" =~ (^| )mkinitcpio($| ) ]] && RELEVANT+=("mkinitcpio") [[ "$packages" =~ (^| )nvidia-dkms($| ) ]] && RELEVANT+=("nvidia-dkms") detect_snapshots local RELEVANT_SOFTWARE="${RELEVANT[*]}" [ -z "$RELEVANT_SOFTWARE" ] && RELEVANT_SOFTWARE="None" echo "$RELEVANT_SOFTWARE" } generate_system_update() { local last_update last_update="$(date -r /var/lib/garuda/last_update +%s 2> /dev/null)" || { echo "Unknown/Never"; return; } local reboot="" if [ "$last_update" -gt "$(date -r /proc +%s)" ]; then reboot=" \033[1;31m↻" fi echo -e "$(date -d"@$last_update" +%F)${reboot}" } [ -t 0 ] && inxi -Faz --zv || inxi -Fazc0 --zv echo -e "\033[1;34mGaruda ($(pacman -Q garuda-common-settings | awk '{print $2}')):\033[0m" install_date="$(head -n1 /var/log/pacman.log | cut -d " " -f1 | cut -c 2-11)" echo -e "\033[1;34m System install date:\033[0m ${install_date}" echo -e "\033[1;34m Last full system update:\033[0m $(generate_system_update)" echo -e "\033[1;34m Is partially upgraded: \033[0m $([ -e /var/lib/garuda/partial_upgrade ] && echo Yes || echo No)" echo -e "\033[1;34m Relevant software: \033[0m $(generate_relevant_software)" detect_dual_boot &> /dev/null echo -e "\033[1;34m Windows dual boot: \033[0m ${DUALBOOT}" echo -e "\033[1;34m Failed units: \033[0m $(systemctl list-units --failed --full --all --plain --no-legend | awk '{printf("%s ",$1)}')" if [ "$1" == "funstuff" ]; then update_count="$(paclog --grep="starting full system upgrade" | wc -l)" echo -e "\033[1;34m Total system updates: \033[0m ${update_count}" echo -e "\033[1;34m --> Updates per week: \033[0m $(( ${update_count}/(($(date +%s) - $(date --date="$install_date" +%s) )/(60*60*24*7)) ))" fi