small bugfixes

This commit is contained in:
crater2150 2023-08-29 11:31:13 +02:00
parent 714a15f664
commit 3cb3440d80
2 changed files with 7 additions and 5 deletions

View file

@ -3,12 +3,13 @@
source ${$(realpath "$0"):h:h}/lib/common.zsh
import-env awesome
ALLARGS=("$@")
zparseopts -D -maxidle:=maxidle -in-chronic=chronic l:=logfile -logfile:=logfile
if [[ $logfile ]]; then
function debug() {
echo "$(date --iso-8601=seconds) $*" >> $logfile
echo "$(date --iso-8601=seconds) $*" >> ${logfile[2]}
}
else
function debug() {}
@ -16,13 +17,14 @@ fi
if [[ ! $chronic ]]; then
debug "Restarting with chronic"
exec chronic $0 --in-chronic $ALLARGS
exec chronic $0 --in-chronic "${ALLARGS[@]}"
fi
if [[ $maxidle ]]; then
idle=$(xprintidle)
maxidle=${maxidle[2]}
debug "Checking idle time: $(xprintidle) / 1000 < $maxidle"
if (($(xprintidle) / 1000 < $maxidle)); then
debug "Checking idle time: $idle / 1000 < $maxidle"
if (($idle / 1000 < $maxidle)); then
debug "Checking pgrep $1: $(pgrep $1)"
if ! pgrep $1; then
debug "Running $*"