summaryrefslogtreecommitdiff
path: root/i3blocks-message.sh
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-05-15 11:57:45 -0400
committerAdam T. Carpenter <atc@53hor.net>2020-05-15 11:57:45 -0400
commit6e14535ef56fd91b05eb170f71f7989d7435d8c3 (patch)
tree9d9e947cd11af17cffa37000f635f682070ed5af /i3blocks-message.sh
parent2930e933305e653f2f26deacd459dd100f257168 (diff)
downloadscripts-6e14535ef56fd91b05eb170f71f7989d7435d8c3.tar.xz
scripts-6e14535ef56fd91b05eb170f71f7989d7435d8c3.zip
added dmenu port handling script, changed thresholds in cpuload
Diffstat (limited to 'i3blocks-message.sh')
-rw-r--r--i3blocks-message.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/i3blocks-message.sh b/i3blocks-message.sh
new file mode 100644
index 0000000..8f7c5e2
--- /dev/null
+++ b/i3blocks-message.sh
@@ -0,0 +1,34 @@
+#!/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