I'm using Android 9 on my Xiaomi Redmi Note 7 Pro and on PC I use Windows 10 and Arch Linux, there are many times when I'm away from my phone and it is charging in a different room or someone else is using it, is there was a way to send over the battery percentage say bp over to my PC at regular intervals via the internet.

There maybe apps that can do this (those answers are welcome) but I'm interested more in a script based approach, do I have to root my phone for doing this or will sh command.sh work.

Ideas I'm thinking of are:

I have Termux installed and my device is not rooted yet how do I proceed.

  • Usually your PC is not exposed to the Internet, therefore a (temporary) storage is needed online. Typical examples are storage services like Dropbox, document services like Google Sheets or messaging systems like Signal or Wire. I am sure for a lot of services termux/Linux scripts exist that allow to store data in one of these services. – Robert Jan 13 at 18:28
  • @Robert Exactly why I was thinking of a copy pasta aka a pastebin service to broadcast my battery status to for example maybe ix.io but I'm sure the people here have something even simpler. Another issue is how I'm going to get the battery percentage in terminal without rooting. – himanshuxd Jan 13 at 18:32

I have made a not so elegant way to do this but any one who can improve upon this or give an better solution should do so.

I'm using gist by Github for broadcasting my battery percentage first to a private file, tried using ix.io which is what I usually use but pkg install ix didn't work on Android terminal the config.guess threw and error saying unable to guess system type anyone doing that should try editing that file and setting default values in it.

Already had Termux installed on my Android with necessary packages and with pkg install termux-battery-status and installing the Playstore api app : https://play.google.com/store/apps/details?id=com.termux.api&hl=en_IN using termux-battery-status | grep percentage | grep -oP '\: (.*?)\,' | grep -Eo '[0-9]{1,3}' gave the battery percentage in terminal.

Finally I set up crontab on Android to do this every 5 minutes with a toggle to turn the script on and off when not required, see https://github.com/termux/termux-app/issues/1091

PS : I'll put the whole script here when I get the cronjob to work perfectly : https://github.com/himanshuxd/bp-broadcast

|improve this answer|||||

You could use Your Phone Companion from Microsoft to link Android to your PC. The battery percentage would be shown at the upper left corner near device icon.

|improve this answer|||||
  • 1
    It won't work when I'm using Ubuntu or Arch plus the permission list for that app is quite taxing. – himanshuxd Jan 14 at 19:05
  • 1
    You could try Find My Device which requires GPS to be active. – Abhishek Kumar Jan 14 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.