From 7a2e43e9da275f9ccddcb68cb1be203a8d19091c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 4 Aug 2024 00:11:12 -0300 Subject: Fix: status: run mrconfig-update less often --- status | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'status') diff --git a/status b/status index 1478c8c..948cba6 100755 --- a/status +++ b/status @@ -77,12 +77,34 @@ function status_run { # Update your mrconfig and check all registered repositories if which mr &> /dev/null; then + local mrconfig="$HOME/.custom/mrconfig-automatic" + local mrconfig_run="0" + + # Run mrconfig-updater if there's still no config + if [ ! -e "$mrconfig" ]; then + mrconfig_run="1" + else + local mrconfig_timestamp="`stat -c '%Z' $mrconfig`" + local timestamp="`date +%s`" + local mrconfig_age="$(( timestamp - mrconfig_timestamp ))" + local mrconfig_interval="3600" + + # Run mrconfig-updater only every hour or so + if (( $mrconfig_age >= $mrconfig_interval )); then + mrconfig_run="1" + fi + fi + + if [ "$mrconfig_run" == "1" ]; then + mrconfig-updater + fi + # Pipe through cat so we don't have to deal with mr's dynamic output weirdness - #mrconfig-updater && mr -m status | cat + #mr -m status | cat # Replace eventual "/mnt/crypt/home/$USER" with "~/" from output # Piping through sed also handles mr's dynamic output weirdness - mrconfig-updater && mr -m status | sed -e "s|/mnt/crypt/home/$USER/|~/|" -e "s|$HOME|~|" + mr -m status | sed -e "s|/mnt/crypt/home/$USER/|~/|" -e "s|$HOME|~|" fi # Use this as an opportunity to save our configs -- cgit v1.2.3