So in MAC, you can install an app called XBAR to run scripts and run it for a period of time like CRON like this screenshot.
In this article, I’ll show you to do similar things in Windows. Here are the steps:
Step 1. Create a folder
Add a folder for your toolbar. In this demo, I will be using the folder “API”
Step 2. Your bash scripts.
The scripts below will fetch some data from API like ETH balance and GPU hash rate for mining
2miners.sh
#!/bin/bash
# Author: John Mark Causing
# Date: Nov 11, 2021
# Description:
# Get ETH balance from 2Miners pool
# Bash script for windows with CRON that appends data to a file name. This will appear in the windows tool bar
# Setup path and JQ
export PATH="/usr/local/bin:$PATH"
path="/mnt/c/API/"
pathfile="/mnt/c/API/BAL"
# Check if files exist then delete
if ls $pathfile* 1> /dev/null 2>&1; then
echo "files do exist"
rm $pathfile*
fi
# 2miner Balance API
JQ=$(command -v jq)
json1=$(curl -s https://eth.2miners.com/api/accounts/0xad26dc72fcf82ce0c3838575624493506bf1d90d) # Get data from 2miners API wallet
balance_none_eth=$($JQ -r ".stats | .balance" <<< $json1) # Get current 1ETH to PHP value
convert=1000000000 # Conversion var
eth_bal=$($JQ -n $balance_none_eth/$convert) # Conversion to ETH
a_rounded=`printf "%.3f" $eth_bal` # Lessen decimal to display the same in 2miners website
# Get updated currency ETH rate to PHP (Philippine Peso) - crypto compare API
ethphprate=$(curl -s "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=PHP")
ethphp=$($JQ -r ".PHP" <<< $ethphprate) # Get current 1ETH to PHP value
RES=$(echo "scale=2; $ethphp*$eth_bal" | bc) # Convert ETH balance to PHP value
eth_php_bal=`printf "%.0f" $RES` # Lessen decimal to display the same in 2miners website
# echo "ETH Bal: $a_rounded [PHP: $eth_php_bal_cg]" # Display real ETH Balance
# echo "ETH: $a_rounded" # Display real ETH Balance
# echo "---"
# echo "ETH Bal: $a_rounded [PHP: $eth_php_bal] Crypto Compare API" # Display real ETH Balance
# Append the data to a file name
newfilename="BAL: $a_rounded PHP: $eth_php_bal";
touch "$path$newfilename"
gminerhashrate.sh
#!/bin/bash
# Author: John Mark Causing
# Date: Nov 11, 2021
# Description:
# Get GPU hashrate for gminer API
# Bash script for windows with CRON that appends data to a file name. This will appear in the windows tool bar
# Setup path and JQ
export PATH="/usr/local/bin:$PATH"
path="/mnt/c/API/"
pathfile="/mnt/c/API/temp.lnk"
rm $path/GPU*
export PATH="/usr/local/bin:$PATH"
JQ=$(command -v jq)
json=$(curl -s https://192.168.1.3:8887/stat) #get api url gmianer
total_gpu=$(jq -r '.devices[] | .name ' <<< $json | wc -l) #total number of GPUs
#loop/get all gpu data, speed/etc
x=0
total_kh=0
while [ $x -ne $total_gpu ]
do
loop_mh=$($JQ -r ".devices[$x] | .speed " <<< $json)
# Sum total mh in this loop
total_kh=`expr $total_kh + $loop_mh`
x=$(( $x + 1 ))
done
#convert kH to Mh
kh=1000
total_mh=`expr $total_kh / $kh`
newfilename="GPU: $total_mh khS";
touch "$path$newfilename"
Step 3. Setup CRON
This is to schedule calling your scripts. For example, below I’ll be running GMiner every 1 minute to fetch the GPU hash rate and 2Miners API will check my ETH balance every 5 minutes
$ crontab -e
# GMiners API hashrate speed
*/1 * * * * /bin/bash /home/jmc/bash_scripts/windows-toolbar.sh
# 2Miners API hashrate speed
*/5 * * * * /bin/bash /home/jmc/bash_scripts/2miners.sh
Results:
So each script will delete the existing file and create a new blank file with the data on its file name.