Monitor the status of your local (or remote) Syncthing
#!/usr/bin/env bash
set -euo pipefail
# <xbar.title>Syncthing</xbar.title>
# <xbar.version>v0.2</xbar.version>
# <xbar.author>blockloop</xbar.author>
# <xbar.author.github>blockloop</xbar.author.github>
# <xbar.desc>Monitor the status of your local (or remote) Syncthing</xbar.desc>
# <xbar.image>https://blockloop.nyc3.digitaloceanspaces.com/images/syncthing.png</xbar.image>
# <xbar.dependencies>curl</xbar.dependencies>
# <xbar.dependencies>jq</xbar.dependencies>
# <xbar.dependencies>bc</xbar.dependencies>
# <xbar.dependencies>dig</xbar.dependencies>
# <xbar.dependencies>awk</xbar.dependencies>
# <xbar.dependencies>xargs</xbar.dependencies>
# <xbar.dependencies>sed</xbar.dependencies>
# <xbar.dependencies>tac</xbar.dependencies>
PATH="/usr/local/bin:/usr/local/opt/coreutils/libexec/gnubin:$PATH"
API_KEY=""
HOST="http://127.0.0.1:8384"
# HiDPI
# ICON_DEFAULT="iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQ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lXUre2sSmvNxrwYj3d/tEV7ibaN6qydW83m1DVwODl+njF9r5xs9wZTZmhEPejhkoYxpuiF9iDDz7I313nAwcO2MnJk5QzX4NhwU4HDAHifYBflZEUU30xPhauZy6/5HGK+qpD3QxBkHS/k21ePZPs+XYmFHldrn2H2+3YO73ez7gbkQiWG0844nA4YMWKFbB48WLAMuQyePPNN2FkZAQwSW0Oh8Nsy5YtPA8gFAqd4SMAXkr5EHz54wJlY8PVKW+cZ55XGxNQdYK+VHOBDYYTvDYtE38+6xy+XoYZGenXLDVb8Hp1jRCYXYLoalu+fv36617AirDLMCsri8tWcL3jNOEJ36uNpfIrDVczN11gUzY2GLDhhD7r9VNs10dXzDh2CspoJyqyG9H0GTOPJgd8/KAEbzKYbGxoaAjvNirr7u5mvBmhzGbepHiz4muxS7JgMHgQn3mj/wLZ/7ksNLknooy9leQJlKaaKlyIaTqMmSQ7TZYeL5xELC36ws8rZj5XdPuikjMnj9d53VJgbKIVL1myRODJh7GGEydOwPDwsJ2MCIrHS/d6vU58HsF8WITzpi8D4FgmQKS+ctwbo8ov0feVk5L8Hrepwblo3IAEOMAJw7Mlds+pX8yrh5yvl0PHyb9lZoaSu7v5TQD41YtXl11hmP0Umw7FHHDwKkBgI8irUf4eMr9gfwU9jDlRPYcfBO7fNdymUfowtseKyU7XJA8mU7/DDcOjfZc8pnpXpGphO0wtng2XT7+cEgze5cOmxBWhhXD16lV75OfwjxKCOYjl+TOc8uTjAMev5fjwvzThiWuCwIsfZo2C+A28N9yhiCRXBFaM3rlqWcYDRtU3Ttsflqqq+3D9UuTZyNMn9l7Akf+HXIP8LjJev8aV48j+A73IR5QUS6z1AAAAAElFTkSuQmCC"
# SCALE_FACTOR="$(gsettings get org.gnome.desktop.interface text-scaling-factor)"
# if (( $(echo "$SCALE_FACTOR == 1" | bc -l) )); then
# regular icons
ICON_DEFAULT="iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAABGdBTUEAALGPC/xhBQAAACBj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igouLy/n27dvc1dXFzfs2MFutzvl8wcaxYxudV8ZTNJ01kTngxTe+XkIb/4yhG0/Pehf/0HTsGGpDXV1dY6GxkY6cOAAlFI4ceIETNPExpoaBINBnxS0VRiWebGpK5bYf3UYQbeEJCCuK6QtNRr77YKSUis0DIMTiQRisRgMw8DZs2fR3t4Oj8cDn88HZl4uZk3rsqX42nf3k7g7keF9zxcg4nXA1G1hSg+ns7o6d+4cpqamcP36dfT29qKsrAyVlZWIRCKora2FlNISixavepi17cNJJe5/dHOSRhIGH325CHtX5xZWbajVBGEwmUxSOp3Gli1bUF9fj2w2C8uy4HK5eHR0FMzcIyfXvgKKjg2T2zsyq+Szvw+lcuJpk19aHAysXbPixrdnvuhPJpOVAGRJSQnl5+ejra0NnZ2d6O3tpdbW1gQRHSQ0foWtDa+h9Uy7cMwJlWkQO8nm8oBEyO/SOh71dryXOLPzdQ3W9lAoFHA4HDw+Pg6lFKSUcaXUMdM0j0rcOo+ejs2wNcHmyXtDqix0BYQ+hlDTNiLZQG5Y+cPHZN+NQaVUOJPJzNV1PQugU0p50DTNZill5l8RAkRHz8PDyQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0wNC0yM1QxNToxODozNC0wNTowMB6YrZYAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMDQtMjNUMTU6MTY6MzgtMDU6MDC2rE/tAAAAAElFTkSuQmCC"
# fi
function hostnameForIP() {
if [ -z "$1" ]; then
return
fi
port="$(echo "$1" | awk -F: '{print $NF}')"
ip="${1//:$port/}"
# strip IPv6 brackets
ip="${ip//[][]/}"
hname="$(dig +short -x "$ip" xargs)"
if [ -n "$hname" ]; then
echo "${hname//\.$/}"
else
echo "$ip"
fi
}
[ -z "$API_KEY" ] && echo "ERROR" && echo "Open this file and set your API_KEY!" && exit 1
if ! curl -s -m 1 "$HOST/rest/system/ping" &> /dev/null; then
echo "| image=${ICON_NOTIFY}"
echo "---"
echo "Open | href=${HOST}"
echo "State: Not connected"
echo "Host: $HOST"
exit 0
fi
STATUS="$(curl -s -m 2 -H "X-API-KEY:$API_KEY" $HOST/rest/system/status)"
uptime_s="$(echo "$STATUS" | jq -r '.uptime')"
uptime_m="$((uptime_s / 60))"
uptime_h="$((uptime_m / 60))"
uptime_d="$((uptime_h / 24))"
uptime_m="$((uptime_m % 60))"
uptime_h="$((uptime_h % 24))"
CONNS="$(curl -s -m 2 -H "X-API-KEY:$API_KEY" $HOST/rest/system/connections)"
CON_ADDRS="$(echo "$CONNS" | jq -r '.connections[] | select(.connected == true) | .address')"
STATE="$(curl -s -m 2 -H "X-API-KEY:$API_KEY" "$HOST/rest/events?event=StateChanged&limit=1")"
CHANGES="$(curl -s -m 1 -H "X-API-KEY:$API_KEY" "$HOST/rest/events?events=LocalChangeDetected,RemoteChangeDetected&limit=50")" || true
cpu="$(echo "$STATUS" | jq -r .cpuPercent)"
cpu=$(echo "scale=2;$cpu" |bc)
state="$(echo "$STATE" | jq -r '.[].data.to')"
[ "$state" == "null" ] && state='idle'
ICON=$ICON_DEFAULT
if [ "$state" == "scanning" ] || [ "$state" == "syncing" ]; then
ICON=$ICON_SYNC
elif [ "$state" == "paused" ]; then
ICON=$ICON_PAUSE
elif [ "$state" == "error" ]; then
ICON=$ICON_NOTIFY
fi
echo "| image=${ICON}"
echo '---'
echo "Open | href=${HOST}"
echo "State: $state"
echo "Uptime: ${uptime_d}d ${uptime_h}h ${uptime_m}m"
printf "CPU: %.*f%%\\n" 2 "$cpu"
echo '---'
echo "Connections"
if [ -z "$CON_ADDRS" ]; then
echo "None"
else
for addr in $CON_ADDRS; do
echo -n '- '
hostnameForIP "$addr"
done
fi
echo '---'
echo "Recent Changes"
echo "$CHANGES" | jq -r '.[] | .data | "-- \(.action)::\t\(.path)"' | uniq | column -t -s $'::' | tac | head
echo '---'