Add `conky-sync-status`

c5f35ccccdeeb5656803b663dfe2b87b9c55ad34
Alexis Sellier committed ago 1 parent 27ee2424
bin/conky-sync-status added +35 -0
1 +
#!/bin/sh
2 +
3 +
REMOTE=share
4 +
5 +
status="$(systemctl --user is-active share-sync)"
6 +
dry=$(rsync --dry-run --checksum --delete -ril ~/share/ $REMOTE:share/)
7 +
8 +
green() {
9 +
  echo -n "+@fg=4;$1+@fg=0;"
10 +
}
11 +
12 +
red() {
13 +
  echo -n "+@fg=3;$1+@fg=0;"
14 +
}
15 +
16 +
if [[ "$dry" ]]; then
17 +
  red "!"
18 +
else
19 +
  green "โœ”"
20 +
fi
21 +
22 +
case "$status" in
23 +
  "active")
24 +
    ping -c1 -w5 $REMOTE 1>/dev/null 2>/dev/null
25 +
26 +
    if [ $? -eq 0 ]; then
27 +
      green "โœ”"
28 +
    else
29 +
      red "!"
30 +
    fi ;;
31 +
32 +
  *)
33 +
    red "โœ˜" ;;
34 +
esac
35 +
echo