Some handy scripts I wrote to customize i3blocks
git clone https://github.com/alrayyes/i3blocks.git
Lists number of Arch Linux package updates available
#!/bin/sh
# Arch upgradeable packages
list=`pacman -Sup 2> /dev/null`
if [ "$list" == ":: Starting full system upgrade..." ]; then
count=""
else
count=`echo "$list" | wc -l`
fi
echo "$count"
[arch-updates]
command=~/i3blocks/archupdates
label=
color=#FF0000
interval=3600
Lists number of Docker containers running
#!/bin/sh
docker ps -q | wc -l | sed -r 's/^0$//g'
[docker-containers]
label=
command=~/i3blocks/container
interval=5
Lists number of unread emails in Gmail inbox
#!/bin/bash
# Requires https://www.google.com/settings/security/lesssecureapps for gmail.
CONFIG_FILE="${BLOCK_INSTANCE}"
CONFIG_FILE=${CONFIG_FILE/\~/$HOME}
# Config file needs the following settings:
#MAIL_USER="[email protected]"
#MAIL_PASSWORD="secret"
if [[ ! -f "${CONFIG_FILE}" ]]; then
echo "${CONFIG_FILE}"
exit 33
fi
source "${CONFIG_FILE}"
COUNT=`curl -su $MAIL_USER:$MAIL_PASSWORD https://mail.google.com/mail/feed/atom || echo "<fullcount>unknown number of</fullcount>"`
COUNT=`echo "$COUNT" | grep -oPm1 "(?<=<fullcount>)[^<]+" `
if [ "$COUNT" = "0" ]; then
echo ""
else
echo $COUNT
fi
[gmail]
command=~/i3blocks/gmail
label=G
instance=~/.mysupersecretgmaillogin
interval=60
color=#00FF00
MAIL_USER="[email protected]"
MAIL_PASSWORD="password123"
Prints your external ip address
#!/bin/sh
ip=$(curl -s icanhazip.com);
if [[ "$BLOCK_BUTTON" -eq 1 ]];
then
netname=$(whois $ip | grep '^netname:' | awk '{print $2}' | tail -1);
echo "$netname"
else
echo "$ip"
fi
[whatismyip]
label=
command=~/i3blocks/whatismyip
color=#00FF00
interval=30
Prints current song playing in cmus
#!/bin/sh
ICON_PLAY="➤"
ICON_PAUSE="Ⅱ"
ICON_STOP="≠"
CUR_ICON=""
INFO_ARTIST=$(cmus-remote -Q | grep ' artist ' | cut -d ' ' -f3-)
INFO_ALBUM=$(cmus-remote -Q | grep ' album ' | cut -d ' ' -f3-)
INFO_TITLE=$(cmus-remote -Q | grep ' title ' | cut -d ' ' -f3-)
PLAYER_STATUS=$(cmus-remote -Q | grep 'status' | cut -d ' ' -f2-)
if [[ "${PLAYER_STATUS}" = "paused" ]]; then
CUR_ICON="${ICON_PAUSE}"
elif [[ "${PLAYER_STATUS}" = "playing" ]]; then
CUR_ICON="${ICON_PLAY}"
else
CUR_ICON="${ICON_STOP}"
fi
if [[ "${INFO_TITLE}" != "" ]] && [[ "${INFO_ARTIST}" != "" ]]; then
echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}"
echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}"
fi
[cmus]
label=
command=~/i3blocks/cmus
interval=5
This theme is released under the MIT License. For more information read the license.