From 92954355bcfbb9f271f5c1afae97ca4479cf3105 Mon Sep 17 00:00:00 2001 From: frrobert2 Date: Sun, 9 May 2021 15:24:12 -0400 Subject: [PATCH] added bash script that uses openssl in place of curl --- notificatorossl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 notificatorossl diff --git a/notificatorossl b/notificatorossl new file mode 100755 index 0000000..bcd142b --- /dev/null +++ b/notificatorossl @@ -0,0 +1,50 @@ +#!/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 + +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 + echo -en "\007" + echo "You have new notifications!" + read -p "Press enter to continue or amfora to go to notifications" answer + case $answer in + amfora) $(amfora gemini://station.martinrue.com/frrobert) + ;; + esac + + lasttime=$notifications + unset my_array + fi + sleep 60 +done + -- 1.8.3.1