1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#!/bin/bash
set -e
"${@}" 3> >(
FRONTEND="${FRONTEND:-pinentry}"
DATAPATH="${DATAPATH:-$HOME/.local/share/equihash}"
read n k
[[ -d "$DATAPATH" ]] || mkdir -p "$DATAPATH"
[[ -f "$DATAPATH/$n-$k" ]] &&
txt="Solving this Equihash challenge will take approximately $(awk '{sum+=$1; ++n} END {printf "%.4f\n", sum/n}' $DATAPATH/$n-$k) seconds" ||
txt="Never saw this Equihash difficulty ($n,$k) before, unknown how long it will take.\nPlease wait."
# this could also be some dbus stuff for popup notifications
# or even conky or other stuff is possible whatever is prefered
case "$FRONTEND" in
zenity) zenity --progress --pulsate --no-cancel --title "Equihash challenge solving..." --text "$txt" & ;;
pinentry) echo -ne "SETTITLE equihash challenge notification\nSETDESC $txt\nMESSAGE\n" | pinentry 1>/dev/null & ;;
esac
pid=$!
read res || true
echo "$res" >>"$DATAPATH/$n-$k"
kill $pid 2>/dev/null
)
|