#!/bin/zsh #dep:xprintidle pgrep chronic ALLARGS=("$@") WINDOW_MANAGER=awesome WM_PID=$(pgrep WINDOW_MANAGER | head -n 1) export "${(@ps:\000:)$(> $logfile } else function debug() {} fi if [[ ! $chronic ]]; then debug "Restarting with chronic" exec chronic $0 --in-chronic $ALLARGS fi if [[ $maxidle ]]; then maxidle=${maxidle[2]} debug "Checking idle time: $(xprintidle) / 1000 < $maxidle" if (($(xprintidle) / 1000 < $maxidle)); then debug "Checking pgrep $1: $(pgrep $1)" if ! pgrep $1; then debug "Running $*" eval "$*" exit $? fi fi else debug "Checking pgrep $1: $(pgrep $1)" if ! pgrep $1; then debug "Running $*" eval "$*" exit $? fi fi