Use Power Management to run xscreensaver program?

Thanks, that lead to more progress, I’ve got to this:

function checkIdle() {
  while true; do
    loginctl show-session "$XDG_SESSION_ID" -p IdleHint -p IdleSinceHint
  done
}

checkIdle | while read prefix count otherstuff; do
  if ((count <=0)); then
    echo No
    exit; fi
  done

Which seems to function, in that it says “No”. So I’ve put the two functions together as below, should it work?

  function watchInhibitions() {
  while true; do
    busctl --user call org.kde.Solid.PowerManagement.PolicyAgent /org/kde/Solid/PowerManagement/PolicyAgent org.kde.Solid.PowerManagement.PolicyAgent ListInhibitions
    sleep 2
  done
}

  function checkIdle() {
  while true; do
    loginctl show-session "$XDG_SESSION_ID" -p IdleHint -p IdleSinceHint
  done
}

checkIdle | while read prefix count otherstuff; do
  if ((count <=600)); then
    exit; else

watchInhibitions | while read prefix count otherstuff; do
  if ((count <= 0)); then
    xscreensaver-command --activate
    xscreensaver-command --watch | while read event otherstuff; do
      if [ "$event" = "UNBLANK" ]; then exit; fi
    done
  fi
  fi
done
done