From dff2f6cd171f91c40d7e2a5ec7b54330c9451c12 Mon Sep 17 00:00:00 2001 From: Ryan Kes Date: Thu, 26 Mar 2020 13:00:09 +0100 Subject: [PATCH] Audit script now caches urls for user convenience --- lighthouse/.local/bin/audit | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/lighthouse/.local/bin/audit b/lighthouse/.local/bin/audit index 26890ea..b9b2bce 100755 --- a/lighthouse/.local/bin/audit +++ b/lighthouse/.local/bin/audit @@ -2,18 +2,27 @@ . $HOME/.cache/wal/colors.sh +cachedUrls=$(cat ~/.cache/audit-urls 2>/dev/null) localServices=$(netstat -ltpn 2>/dev/null | grep "node" | awk '{ print "http://"$4 }') -url="$(echo -e "$localServices\nOther" | dmenu -i -nb "$color0" -nf "$color15" -sb "$color1" -sf "$color15" "$@")" -if [ "$url" == "Other" ]; then - read -r -p "Url: " url -fi - -rm -f "$HOME"/Downloads/lighthouse.html -env CHROME_PATH=/usr/local/bin/brave lighthouse --output-path="$HOME"/Downloads/lighthouse.html "$url" - -if [ -f "$HOME"/Downloads/lighthouse.html ]; then - setsid /usr/local/bin/brave ~/Downloads/lighthouse.html -else - read -r -n 1 -p "Something went wrong. Press any key to exit." +test -n "$localServices" && dmenUrls+="$localServices" +test -n "$cachedUrls" && dmenuUrls+="$cachedUrls" + +url="$(echo -e "$dmenuUrls" | uniq | sort | dmenu -i -nb "$color0" -nf "$color15" -sb "$color1" -sf "$color15" "$@")" + +if [[ -n "$url" && "$url" != "http://" && "$url" != "https://" ]]; then + rm -f "$HOME"/Downloads/lighthouse.html + env CHROME_PATH=/usr/local/bin/brave lighthouse --output-path="$HOME"/Downloads/lighthouse.html "$url" + + if [ -f "$HOME"/Downloads/lighthouse.html ]; then + setsid /usr/local/bin/brave ~/Downloads/lighthouse.html + else + read -r -n 1 -p "Something went wrong. Press any key to exit." + fi + + # Cache list of audit urls used with dmenu + if [[ ! $(grep "$url" ~/.cache/audit-urls) ]]; then + echo "$url" >>~/.cache/audit-urls + fi + fi