is it possible to remotely see laptop battery percentage, or output it into a web browser?
Posted by jhsevs@reddit | learnprogramming | View on Reddit | 2 comments
Long story long, I do IRL streaming using a homemade streaming backpack. My backpack uses a laptop. It works well, but I would like to be able to know my battery percentage without having to use remote desktop.
If I can output the battery percentage directly onto the stream, that would be perfect. I am using Open Broadcaster Software (OBS) for streaming.
I cannot use screen capture in OBS because as soon as I close the laptop screen, the screen capture freezes. I don't think there is a viable workaround to this.
However, the software Core Temp has a remote server plugin which outputs stats like cpu temperature etc to a local web server. In OBS you can add a web browser as an overlay source. Unfortunately Core Temp does not output any battery related stats. I had the idea of contacting the Core Temp author and ask if he would like to add this functionality to CT so that I could use the CT web server as a source in OBS, but I doubt he has time to bother with my suggestion. Also you can't use the CT web server directly as a source, as it has no UI elements, it only outputs info/stats as a constant stream of ascii characters if I understand it correctly. I don't know how to make it into a UI thing that OBS can capture and display.
I have tried googling this and found something called "getBattery() method" and "the Battery status API". Is this something you code into a HTML document? There was an example of some code on stackoverflow but it used {} symbols so I don't think it was HTML code. I tried pasting it into a HTML document but it didn't show anything useful when I opened the document in a browser. It might also only be meant to be used with mobile phones instead of laptops?
Is there a simple website online that just scans your battery status and outputs it on screen? I have tried looking but since google is AI riddled, I'm not getting any results but you guys might.
Even though I have a degree in electrical automation engineering and know how to program a PLC, I have 0 idea how to program a computer. So bear with me.
NationalOperations@reddit
What is the device you want to view the battery percentage on? I'm assuming a phone? If so does the laptop have network connection?
captainAwesomePants@reddit
You know, usually the answer to these questions is "no, you can't find out that sort of thing about a computer from a web browser," but as you noted here, battery life totally is. You use JavaScript. Here's an example:
This is JavaScript and not raw HTML. Using that line, and calling it repeatedly to get the HTML to update, is a bit trickier than using normal HTML without any script. There are a bunch of tutorials out there, but the gist of it is that you stick it inside special "script" HTML tags. And to make it change every so often, you set up a timer to call it over and over and have it update the value of an HTML element with the results.