#!/usr/bin/env bash # notifitcatorossl is a fork of https://github.com/ThatsRedacted/StationNotifier # This program uses openssl rather than curl to connect to a gemini site` key='/home/frrobert/.config/amfora/7debbb3fae40dbe77746aa465300febaec5abb778faa8a550f8e5924f0977983.key' cert='/home/frrobert/.config/amfora/7debbb3fae40dbe77746aa465300febaec5abb778faa8a550f8e5924f0977983.crt' connectto=30 howoften= tmpfile=$(mktemp /tmp/not.XXXXXX) url="gemini://station.martinrue.com/frrobert" lasttime=0 trap ctrl_c INT function ctrl_c() { rm -f $tmpfile exit 0 } while [ true ] do 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") timeout $connectto openssl s_client -crlf -quiet -key $key -cert $cert -connect "$domain:1965" <<<"$url" 2>/dev/null >> $tmpfile IFS=' ' read -ra my_array <<< $(cat $tmpfile | grep '/notifications') notifications=${my_array[2]} echo "" > $tmpfile if [[ $notifications -gt $lasttime ]]; then new=$(expr $notifications - $lasttime) echo -en "\007" echo "You have $notifications notifications and $new new notifications!" read -p "Press enter to continue, or either type amfora or lagrange to go to notifications" answer case $answer in amfora) amfora $url clear ;; lagrange) lagrange $url clear ;; *) clear ;; esac echo "waiting for new notifications" lasttime=$notifications unset my_array fi sleep 600 done