You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
879 B
Bash

#!/bin/sh
/usr/local/bin/i3status | while :
do
read line
if echo "${line}" | grep -Pq '^\{"version":\d\}$' ; then
echo $line
elif echo "${line}" | grep -Pq '^\[$' ; then
echo $line
else
echo -n "["
line=`echo "${line}" | sed 's/^,\{0,1\}\[//' | sed 's/\]$//'`
NB_UPDATES=`/sbin/checkupdates | /sbin/wc -l`
NB_UPDATES_COLOR="#40AA40"
if [ $NB_UPDATES -ge 25 ] ; then
NB_UPDATES_COLOR="#FF0000"
elif [ $NB_UPDATES -ge 10 ] ; then
NB_UPDATES_COLOR="#FF8C00"
fi
echo -n "{"
echo -n "\"name\":\"updates\","
echo -n "\"full_text\":\"pending updates: ${NB_UPDATES} \","
echo -n "\"color\":\"${NB_UPDATES_COLOR}\","
echo -n "\"markup\":\"pango\""
echo -n "},"
echo "$line]" || exit 1
echo -n ","
fi
done