#!/usr/bin/env bash

SCRIPT_DIR=$(dirname $(realpath $0))
BOOK_DIR=${SCRIPT_DIR/\/.Books/}

# PERIOD=10

while [[ ! `pgrep -f "manuskript $1"` ]]; do
  sleep 0.5
done
notify-send "Making backups of $1 every $PERIOD seconds."
tick=1
while [[ `pgrep -f "manuskript $1"` ]]; do
  sleep 1
  if [[ $tick -ge $PERIOD ]]; then
    committy "$1"
    tick=0
  fi
  tick=$(( $tick + 1 ))
done
notify-send "No longer making backups of $1."
rm -f $BOOK_DIR/nohup.out
