#!/bin/bash # expensiveClock # required: firefox, jp2a, imagemagick (just for png2jpg) # checks command -v chromium >/dev/null 2>&1 || { echo "I need chromium, exiting." >&2; exit 1; } command -v jp2a >/dev/null 2>&1 || { echo "I need jp2a, exiting." >&2; exit 1; } command -v convert >/dev/null 2>&1 || { echo "I need im convert, exiting." >&2; exit 1; } # clear once clear printf "\\33[?25l" # hide cursor https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797 # center text custom centertext(){ columns=$(tput cols) string="$1" printf "%*s\\n" $(((${#string}+columns)/2)) "${string//R/ }" } # tmp dir http://mywiki.wooledge.org/BashFAQ/062 tmp="/tmp/$RANDOM-$$" trap '[ -n "$tmp" ] && rm -fr "$tmp" ; printf "\\33[?25h"' EXIT # unhide cursor on exit mkdir -m 700 "$tmp" || { echo '!! unable to create a tmpdir' >&2; tmp=; exit 1; } # scripted svg found on web cat > "$tmp/analog.svg" << EOF EOF main () { # main #firefox --screenshot --window-size=200,200 "$tmp/woot.png" "file:///$tmp/analog.svg" #chromium --disable-gpu --no-sandbox --headless --hide-scrollbars --temp-profile --window-size=1000,1000 --screenshot="$tmp/woot.png" "file:///$tmp/analog.svg" 2>/dev/null || exit chromium --headless --disable-gpu --no-sandbox --disable-setuid-sandbox --hide-scrollbars --temp-profile --window-size=1000,1000 --screenshot="$tmp/woot.png" "file:///$tmp/analog.svg" 2>/dev/null || exit convert "$tmp/woot.png" -resize 1100\!x1000 "$tmp/woot.jpg" || exit # fix final aspect ratio by resizing jp2a -f --chars="R.xX" "$tmp/woot.jpg" > "$tmp/tmp.txt" || exit # using 'R' as a placeholder for easier centering, will be replaced with space # center printf "\\033[H" # cursor to home while read -r line ; do centertext "$line" done <"$tmp/tmp.txt" } # loop 4ever while true; do # updating each full minute main sleep $((60 - $(date +%s) % 60)) done