Created
May 24, 2021 15:39
-
-
Save reinefjord/cf4b42c9ba8f87a988bc273474d6ef38 to your computer and use it in GitHub Desktop.
Adding custom script output to i3status json (output_format = i3bar)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
i3status | { | |
read -r first # read version object | |
echo "$first" # output version object as is | |
# read json array stream and collect each element | |
jq -c --stream --unbuffered 'fromstream(1|truncate_stream(inputs))' | { | |
# start json array | |
echo '[' | |
# read each json object (arrays) | |
while read -r line | |
do | |
new=$(ls ~/Mail/account/Inbox/new | wc -l) | |
mail="{\"name\": \"mail\", \"markup\": \"none\", \"full_text\": \"mail: $new\"}" | |
# add $mail object in front of array and print | |
echo "$line" | jq --unbuffered -c --argjson mail "$mail" '[ $mail ] + .' | |
echo ',' | |
done | |
echo ']' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment