Skip to content

Instantly share code, notes, and snippets.

@aoleg94
Created May 23, 2017 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aoleg94/4fabeb8948ec216ab593cb546cc4f095 to your computer and use it in GitHub Desktop.
Save aoleg94/4fabeb8948ec216ab593cb546cc4f095 to your computer and use it in GitHub Desktop.
Yandex.Disk i3blocks widget
#!/bin/bash
if [ -n "$BLOCK_BUTTON" ]; then
case $BLOCK_BUTTON in
1) yandex-disk start ;;
2) yandex-disk stop ;;
esac
fi 2>&1 >/dev/null
T=`LC_ALL=C yandex-disk status | head -n2`
STATUS=`echo $T | grep -Po 'status: \w+'`
PROGRESS=`echo $T | grep -Po ' \(\d+\s*%\)'`
[ -z "$T" -o -z "$STATUS" ] && STATUS="status: down"
echo "YD: ${STATUS:8}$PROGRESS"
echo "YD: ${STATUS:8}$PROGRESS"
if [ "${STATUS:8}" == "idle" ]; then
echo '#00FF00'
elif [ -z "$T" ]; then
echo '#FF0000'
elif echo "$T" | grep -q Error; then
echo '#FF0000'
else
echo '#FFFF00'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment