forked from matryer/xbar-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbgo.2m.sh
executable file
·28 lines (22 loc) · 931 Bytes
/
bgo.2m.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# <bitbar.title>BGO</bitbar.title>
# <bitbar.version>v1.0.1</bitbar.version>
# <bitbar.author>Justin Honold</bitbar.author>
# <bitbar.author.github>astrostl</bitbar.author.github>
# <bitbar.desc>Checks for active turns at http://www.boardgaming-online.com/ every two minutes</bitbar.desc>
# <bitbar.image>https://cloud.githubusercontent.com/assets/1126471/12794798/82c49950-ca7c-11e5-855b-b1c69a0f9f31.png</bitbar.image>
# <bitbar.dependencies></bitbar.dependencies>
bgo_login='LOGIN'
bgo_pass='PASSWORD'
url="http://www.boardgaming-online.com/"
data="&identifiant=${bgo_login}&mot_de_passe=${bgo_pass}"
fetch() { curl --cookie-jar - --data "$data" --location --silent "$url"; }
extract() { sed -n '/^nbp=/{s/nbp=\([0-9]*\);/\1/p;q;}'; }
turns="$(extract < <(fetch))"
if ((turns < 1)); then
echo "BGO: 0"
else
echo "BGO: $turns | color=red"
fi
echo "---"
echo "Play | href=http://www.boardgaming-online.com/"