#!/bin/bash # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?. PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR idle_limit=$((1000 * 60 * 45)) idle_time=$(sudo -u '#1000' xprintidle 2>/dev/null) ||: if [[ $idle_time && $idle_limit -lt $idle_time ]]; then btrbk run fi