#!/bin/sh ticker_length=5 # words # Echo the text the ticker should scroll over. No newlines! init_ticker() { echo $(fortune | tr -d '\b\r\\' | tr -s '\n\t\v\f' ' ' | tr -s '"' "'") } # Cut up text for ticker tape. gen_ticker() { echo $( echo $text | cut -d' ' -f$word_index-$(( $word_index + $ticker_length - 1 )) ) } while true; do # If ticker text is empty, re-initialize text and word index. Then generate # ticker text. [ -z "$ticker_text" ] && word_index=1 && text=$(init_ticker) ticker_text=$(gen_ticker) && ((word_index += 1)) # Print i3status header string. printf ",[{" # Print ticker tape JSON. printer "$ticker_text" "left" 250 # Print the rest of the status string. echo "${line#,\[}" #printf "%s" $line done