Skip to content

Instantly share code, notes, and snippets.

@yuhangch
Last active March 24, 2023 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuhangch/c403e132e21d65a3616db1da85fdafec to your computer and use it in GitHub Desktop.
Save yuhangch/c403e132e21d65a3616db1da85fdafec to your computer and use it in GitHub Desktop.
SwiftBar ETH gas price
#!/bin/bash
# <xbar.title>ETH Gas Price</xbar.title>
# <xbar.version>v2.0.1</xbar.version>
# <xbar.author>Biran Yucel</xbar.author>
# <xbar.author.github>biranyucel</xbar.author.github>
# <xbar.desc>ETH GasPrice forecast system.</xbar.desc>
# <xbar.image>https://i.imgur.com/f1hPKO2.png</xbar.image>
# <xbar.abouturl>https://ethgasstation.info/</xbar.abouturl>
#
#ETH GasPrice forecast system based on SparkPool Pending Transaction Mempool
# only keep slow gas price, set different color for <15 15 >20.
response=$(curl -s https://beaconcha.in/api/v1/execution/gasnow)
read code rapid fast standard slow timestamp <<<${response//[^0-9]/ }
gas=${slow:0:((${#slow} - 9))}
color=green
if [[ $gas -gt 15 ]]
then
color=purple
elif [[ $gas -gt 20 ]]
then
color=orange
fi
echo "Gas ${gas} | color=${color}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment