#!/usr/bin/env sh
# wallstreet widget: news pictures as coloured ASCII art (jp2a)
#
# Part of wallstreet.  Copyright 2014-2026 Dustin Kirkland
# <dustin.kirkland@gmail.com>, macOS port and data sources 2026.
# Licensed under the Apache License, Version 2.0; see LICENSE.

PKG=wallstreet
WSDATA="$(dirname "$0")/../../share/$PKG/wsdata"
# Ctrl-C in any pane ends the show: close the window all widgets live in
quit() {
	[ -n "$TMUX_PANE" ] && tmux kill-window -t "$TMUX_PANE" >/dev/null 2>&1
	exit 0
}
trap quit INT QUIT TERM

command -v jp2a >/dev/null 2>&1 || exit 1
while true; do
	f=$("$WSDATA" image) || { sleep 10; continue; }
	clear
	jp2a -b --colors --term-fit "$f"
	sleep 5
done
