diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-08-04 00:11:12 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-08-04 00:11:12 -0300 |
commit | 7a2e43e9da275f9ccddcb68cb1be203a8d19091c (patch) | |
tree | 6029305917e36e6ad479d4a867f5a55a04a53472 | |
parent | 7854ce57a1708324ae178fb3f3bef2752483ee4d (diff) | |
download | scripts-7a2e43e9da275f9ccddcb68cb1be203a8d19091c.tar.gz scripts-7a2e43e9da275f9ccddcb68cb1be203a8d19091c.tar.bz2 |
Fix: status: run mrconfig-update less often
-rwxr-xr-x | status | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -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 |