#!/bin/sh
# Render total duration; enforcement is independent of this UI.
deadline=${1:-0}
case "$deadline" in ''|*[!0-9]*) exit 0 ;; esac
[ "$deadline" -gt 0 ] || exit 0
now=$(cut -d. -f1 /proc/uptime)
remaining=$((deadline - now))
[ "$remaining" -ge 0 ] || remaining=0
if [ "$remaining" -le 60 ]; then
    colour='#[fg=colour231,bg=colour1,bold]'
else
    colour='#[fg=colour238,bg=colour148]'
fi
printf '%s Duración restante: %ss #[default]' "$colour" "$remaining"
