From 6089e29bd94ab7d2c69ad99a5d37a5c4e15a9602 Mon Sep 17 00:00:00 2001 From: TNE Date: Sun, 13 Mar 2022 16:10:53 +0100 Subject: [PATCH] Add reboot icon next to full system update text if the user has not rebooted since the last full update --- PKGBUILD | 2 +- usr/bin/garuda-inxi | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index df710e1..1c967c9 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ # Maintainer: Librewish pkgname=garuda-common-settings -pkgver=2.5.5 +pkgver=2.5.6 pkgrel=1 arch=('any') url="https://gitlab.com/garuda-linux/themes-and-settings/settings/$pkgname" diff --git a/usr/bin/garuda-inxi b/usr/bin/garuda-inxi index 188b856..e18c949 100755 --- a/usr/bin/garuda-inxi +++ b/usr/bin/garuda-inxi @@ -16,15 +16,15 @@ detect_dual_boot() { detect_snapshots() { if [ -d /.snapshots ] || pacman -Qq snapper-support &> /dev/null; then - SNAPSHOTS="Snapper" + echo "Snapper" elif [ -d /run/timeshift ] || pacman -Qq timeshift-support &> /dev/null; then - SNAPSHOTS="Timeshift" + echo "Timeshift" elif pacman -Qq snapper &> /dev/null; then - SNAPSHOTS="Snapper (maybe)" + echo "Snapper (maybe)" elif pacman -Qq timeshift &> /dev/null; then - SNAPSHOTS="Timeshift (maybe)" + echo "Timeshift (maybe)" else - SNAPSHOTS="None/Undetected" + echo "None/Undetected" fi } @@ -33,22 +33,31 @@ generate_relevant_software() { systemctl is-enabled tlp &> /dev/null && RELEVANT+=("tlp") systemctl is-active NetworkManager &> /dev/null && RELEVANT+=("NetworkManager") systemctl is-active connman &> /dev/null && RELEVANT+=("connman") - RELEVANT_SOFTWARE="${RELEVANT[*]}" + 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 || inxi -Fazc0 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 $(date -r /var/lib/garuda/last_update +%F 2> /dev/null || echo "Unknown/Never")" +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)" -generate_relevant_software -echo -e "\033[1;34m Relevant software: \033[0m ${RELEVANT_SOFTWARE}" +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}" -detect_snapshots -echo -e "\033[1;34m Snapshots: \033[0m ${SNAPSHOTS}" +echo -e "\033[1;34m Snapshots: \033[0m $(detect_snapshots)" 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)"