Fifo (unix named pipe) - nimaaskarian/goje GitHub Wiki
you can use --fifo
cli argument (or the config, or env var) to pass the path to a fifo to goje. goje would initialize this file as a fifo, and write the timer's json to it on all the timer events.
however on Windows, this option is treated as a normal file (as we have no fifos on Windows, and i don't wanna deal with windows named pipes for now). goje would just write on it without initializing it as a fifo.
an example would be like this:
goje --fifo ~/.config/goje/fifo
then, we can rewrite the goje-client.sh from dwmblock integration like so:
GOJE_FIFO=~/.config/goje/fifo
while true; do
while read -t 2 -r line <> $GOJE_FIFO; do
readarray -t arr <<< "$(echo "$line" | jq -r '.Duration, .Mode, .FinishedSessions, .Config.Sessions')"
duration=$((arr[0]/1000000000))
if [ "$duration" -ge 3600 ]; then
duration=$(date -d "@$duration" -u +%T)
else
duration=$(date -d "@$duration" -u +%M:%S)
fi
case "${arr[1]}" in
0)
mode=
;;
1)
mode=
;;
2)
mode=
;;
esac
echo "$mode $duration ${arr[2]}/${arr[3]}" > /tmp/goje_output
pkill -35 dwmblocks
done
if ! [ -e $GOJE_FIFO ]; then
echo > /tmp/goje_output
pkill -35 dwmblocks
while ! [ -e $GOJE_FIFO ]; do
sleep 1
done
fi
done
this should be much more resource efficient than the json stream approach used in the dwmblocks.
i also suggest you use the $GOJE_FIFO
variable instead, so you can have a persistent fifo path across the script and goje.