--- /dev/null
+#!/usr/bin/env bash
+#Forked from https://gitlab.com/uoou/dotfiles/-/tree/master/stow/bin/home/drew/.local/bin/lace
+# Modified to show date rather than how many days ago by frrobert2
+
+if [ -z "$XDG_CONFIG_HOME" ];then
+ config_place="$HOME/.config/lace"
+else
+ config_place="$XDG_CONFIG_HOME/lace"
+fi
+[[ ! -d "$config_place" ]] && mkdir -p $config_place
+subsfile="$config_place/subs"
+
+red="[31m"
+blue="[34m"
+nc="[m"
+esc=$(echo -e "\033")
+tmpfile=$(mktemp /tmp/lace.XXXXXX)
+
+function dohelp() {
+ echo -e "\nUsage:\n"
+ echo -e "\t$(basename "$0") - read subscriptions\n"
+ echo -e "\t$(basename "$0") nope - read subscriptions without pager\n"
+ echo -e "\t$(basename "$0") subs - list subscriptions\n"
+ echo -e "\t$(basename "$0") sub nickname url - add subscription, e.g.:"
+ echo -e "\t$(basename "$0") sub Drew gemini://friendo.monster/tiny.gmi\n"
+ echo -e "\t$(basename "$0") unsub nickname - remove subscription, e.g.:"
+ echo -e "\t$(basename "$0") unsub Drew\n"
+ echo -e "\t$(basename "$0") update - redownload script to location of current script (might need sudo, depending on location)\n"
+ exit
+}
+
+function timeline() {
+ while read f;do
+ local user=$(awk '{print $2}' <<< "$f")
+ local url=$(awk '{print $1}' <<< "$f")
+ if [[ "$url" != *://* ]];then
+ domain="$url"
+ url="gemini://$url"
+ else
+ domain=$(sed 's/gemini:\/\///' <<< "$url")
+ fi
+ if [[ "$url" != *.*/*.* ]] && [[ $url != */ ]];then
+ url="$url/"
+ fi
+ domain=$(sed 's/\/.*$//' <<< "$domain")
+ fav=$(openssl s_client -crlf -quiet -connect "$domain:1965" <<<"gemini://$domain/favicon.txt" 2>/dev/null | sed -e '1d')
+ if [ ! -z "$fav" ];then
+ user="$fav $user"
+ fi
+ openssl s_client -crlf -quiet -connect "$domain:1965" <<<"$url" 2>/dev/null | sed -e '1d' | sed -n '/##/,$p' | sed -e "s/^\(## .*\)$/\1\n${esc}$red$user${esc}$nc ($domain)/g" >> $tmpfile
+ [[ ! -z $(sed -n '$p' $tmpfile) ]] && echo "" >> $tmpfile
+ done <"$subsfile"
+ cat $tmpfile | sed -r ':r;/(^|\n)$/!{$!{N;br}};s/\n/\v/g' | sed -rn '/^## .*/p' | sed -e 's/\v/\n/g' | sed -e "s/^## \(.*\)/date -d '\1' +%s/e" | sed -r ':r;/(^|\n)$/!{$!{N;br}};s/\n/\v/g' | sort -r | sed -e 's/\v/\n/g' > $tmpfile
+
+ sed -i "s/\(^[0-9]\{8,\}$\)/date -d @\1/e" $tmpfile
+ if [[ "$1" == "nope" ]];then
+ cat $tmpfile && rm -f $tmpfile
+ else
+ less -RisW $tmpfile && rm -f $tmpfile
+ fi
+}
+
+if [[ "$1" == "help" ]] || [[ "$1" == "--help" ]] || [[ "$1" == "-help" ]] || [[ "$1" == "-h" ]];then
+ dohelp
+elif [[ "$1" == "sub" ]];then
+ [[ "$#" -ne 3 ]] && dohelp
+ echo "$3 $2" >> $subsfile && echo "added $2 to subscriptions"
+elif [[ "$1" == "unsub" ]];then
+ [[ "$#" -ne 2 ]] && dohelp
+ if grep " $2$" $subsfile 1>/dev/null;then
+ sed -i "/ $2$/d" $subsfile &&
+ echo "removed subscription to $2"
+ else
+ echo "subscription \"$2\" does not exist"
+ fi
+elif [[ "$1" == "subs" ]];then
+ awk '{print $2" ("$1")"}' $subsfile
+elif [[ "$1" == "update" ]];then
+ curl https://gitlab.com/uoou/dotfiles/-/raw/master/stow/bin/home/drew/.local/bin/lace > "${BASH_SOURCE[0]}"
+else
+ now_unix="$(date +'%s')"
+ if [[ "$1" == "nope" ]];then
+ timeline nope
+ else
+ timeline
+ fi
+fi