#!/bin/bash
state=0
while true;
do
  sleep 1s
  status=$(journalctl -u etapkilit -n 1);
  status2=(${status// / })
  # lock-screen
  len=${#status2[@]}
  echo ${status2[len-2]}
  if [ ${status2[len-2]} -eq 0 ]
  then
    if [ "$state" -eq "0" ]
    then
      state=1
      lock-screen &
    fi
  else
    state=0
    pkill lock-screen
  fi
done