i3bar-protocol: add example (illustration-only!) shell script, clarify {"version":1} header

This commit is contained in:
Michael Stapelberg
2012-08-12 18:47:24 +02:00
parent e53405c216
commit f94edd9fc3
2 changed files with 37 additions and 1 deletions

29
contrib/trivial-bar-script.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
# vim:ts=4:sw=4:expandtab
# © 2012 Michael Stapelberg, Public Domain
# This script is a trivial shell script to send your own output to i3bar while
# using the JSON protocol.
#
# It is ugly and that is inherent to using JSON with shell scripts. You
# _really_ should not do that. See i3status or i3statuss contrib/ directory
# for examples of how to handle the output in higher-level languages.
#
# This example is purely for illustration of the protocol. DO NOT USE IT IN THE
# REAL WORLD.
# Send the header so that i3bar knows we want to use JSON:
echo '{ "version": 1 }'
# Begin the endless array.
echo '['
# We send an empty first array of blocks to make the loop simpler:
echo '[]'
# Now send blocks with information forever:
while :;
do
echo ",[{\"name\":\"time\",\"full_text\":\"$(date)\"}]"
sleep 1
done