Dwmblocks integration - nimaaskarian/goje GitHub Wiki

dwmblocks is a daemon written in C which handles the dwm bar perfectly.

if you wanna integrate a responsive, event based goje module in dwmblocks, you can run a curl client that listens to the json timer stream. you take a look at environment variables, and use the $GOJE_HTTP_ADDRESS variable instead of the hardcoded localhost:7900.

the example below uses the waffle bitmap icons (which i haven't found the source i've downloaded this from. i had this for years and i'm sure you nerds will figure it out), and looks something like this:

dwmblocks goje pomodoro dwmblocks goje short break dwmblocks goje long break

while true; do
  curl -N localhost:7900/api/timer/stream 2> /dev/null | while read -r line; do 
    if [ "$line" != data* ](/nimaaskarian/goje/wiki/-"$line"-!=-data*-); then
      continue
    fi
    readarray -t arr <<< "$(echo "${line:5}" | 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
  echo > /tmp/goje_output
  pkill -35 dwmblocks
  while ! pkill -0 goje; do
    sleep 1s
  done
done

this is a bash script that runs a curl client to goje's stream, and writes the output to /tmp/goje_output, also sending dwmblock a 35 signal on write.

if you look for a more resource friendly approach, i suggest you take a look at fifos.

in your blocks.h then, you can add the block below.

	{" ", "cat /tmp/goje_output",					0,		1},

which tells dwmblock not to update the timer on an interval, but on a signal (1 means SIGRTMIN + 1 = 35).