Created
May 23, 2017 13:13
-
-
Save aoleg94/4fabeb8948ec216ab593cb546cc4f095 to your computer and use it in GitHub Desktop.
Yandex.Disk i3blocks widget
This file contains hidden or 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 | |
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