#!/usr/bin/env sh
# wallstreet widget: news headlines, one after the other
#
# 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

printf '\033[38;5;226m'
while true; do
	"$WSDATA" headlines | sort -R | while IFS= read -r line; do
		printf '%s  %s\n' "$(date +%H:%M)" "$line"
		sleep 2
	done
	sleep 5
done
