Skip to content

Instantly share code, notes, and snippets.

@gautamkrishnar
Last active April 29, 2023 09:24
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 gautamkrishnar/8b1fe4f5537aacf72c0ef8e3cdcbe95c to your computer and use it in GitHub Desktop.
Save gautamkrishnar/8b1fe4f5537aacf72c0ef8e3cdcbe95c to your computer and use it in GitHub Desktop.
Automated script to fetch current and daily BSNL network usage and show it on your MacOS menu bar

Preview

Screenshot 2022-04-13 at 1 03 23 PM

How to use

  1. Open your terminal
  2. Install brew if it is not installed: https://brew.sh/
  3. Install jq by running the following command
brew install jq
  1. Download and install https://xbarapp.com/
  2. Open Xbar
  3. Click on Xbar on your menu bar and select Open Plugin Folder option
  4. Create a file named bsnl_usage-5m-sh in that folder with the above contents
  5. Click on xbar again and select "Refresh all" option
#!/usr/bin/env bash
curl 'https://redirect1.bbportal.bsnl.co.in/portal/fetchUserQuotaPM.do' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36' \
--data-raw \
'actionName=manual&_search=false&rows=4&page=1&sidx=&sord=asc' \
--silent | /usr/local/bin/jq --raw-output '.rows[0] | "\(.totalUsage)\n---\nToday \(.dailyTotalUsage)"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment