matryer / xbar-plugins

Plugin repository for xbar (the BitBar reboot)
https://xbarapp.com
2.46k stars 1.04k forks source link

re: Bandwidth #819

Closed andybrucenet closed 7 years ago

andybrucenet commented 7 years ago

FAO: (@skibz)

Hi - here's my take on the plugin. I use iproute2 tools and get the first default route. Also modified the initial display to make it smaller.

Let me know if you want a PR or if this paste is enough.

Thanks!

#!/usr/bin/env bash

# <bitbar.title>Bandwidth</bitbar.title>
# <bitbar.version>v0.0.0</bitbar.version>
# <bitbar.author>Ant Cosentino</bitbar.author>
# <bitbar.author.github>skibz</bitbar.author.github>
# <bitbar.desc>Displays TX and RX bitrate of your main ethernet interface in the status bar and hides other interfaces in the context menu.</bitbar.desc>
# <bitbar.dependencies>ifstat</bitbar.dependencies>
# <bitbar.image>https://cloud.githubusercontent.com/assets/2462211/12748504/584bbcea-c9b3-11e5-8109-ad8fdcefdc75.png</bitbar.image>

export PATH="/usr/local/bin:${PATH}"
INTERFACES=$(ifconfig -lu)
DEFAULT_DEV=$(ip route | grep default | head -n 1 | sed -e 's#^.* dev \(.*\)#\1#')
[ x"$DEFAULT_DEV" = x ] && DEFAULT_DEV='en0'

echo "${DEFAULT_DEV}:▼ $(ifstat -n -w -i $DEFAULT_DEV 0.1 1 | tail -n 1 | awk '{print $1, "-", $2;}')▲| size=10"
echo "---"
for INTERFACE in ${INTERFACES}; do
  if [[ ${INTERFACE} != "$DEFAULT_DEV" ]]; then
    echo "${INTERFACE}: ▼ $(ifstat -n -w -i "${INTERFACE}" 0.1 1 | tail -n 1 | awk '{print $1, " - ", $2;}') ▲ | size=10"
  fi
done
skibz commented 7 years ago

hi @andybrucenet

please pull request this revision and link to it here?

i'd love for the revision to be attributed to your github identity. however, i'm not sure if the xml metadata supports multiple authors. if it does not, then just replace me.

side note: didn't realise, but someone also forked my plugin a while back.