From 83fb9a083a81d1c40372772b997638c2951be568 Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Thu, 2 Mar 2023 13:20:22 +0100 Subject: [PATCH] new script: cronhelp --- misc/cronhelp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 misc/cronhelp diff --git a/misc/cronhelp b/misc/cronhelp new file mode 100755 index 0000000..974a7b5 --- /dev/null +++ b/misc/cronhelp @@ -0,0 +1,20 @@ +#!/bin/zsh +#dep:xprintidle pgrep chronic + +ALLARGS=("$@") + +zparseopts -D -maxidle:=maxidle -in-chronic=chronic + +if [[ ! $chronic ]]; then + exec chronic $0 --in-chronic $ALLARGS +fi + +if [[ $maxidle ]]; then + if (($(xprintidle) / 1000 < $maxidle)) && ! pgrep $1; then + eval "$*" + exit $? + fi +elif ! pgrep $1; then + eval "$*" + exit $? +fi