Home > OS >  How to print the battery consumption in linux terminal/genmon?
How to print the battery consumption in linux terminal/genmon?

Time:10-17

So i have two battery. On my panel i have to add 2 generic monitor(xfce panel) to see what does my system battery usage. enter image description here

I use this line to print it: awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT1/power_now (this is my second battery)

I would like to make a "script" to do this but only in one generic monitor. Like if Bat0 is 0 then print Bat1 or i dont know.

Sorry for the non technical explanation. I hope you guys can understand this.

Have a great day!

CodePudding user response:

Final and working solution, at least what i have experienced. Thanks for your help.

if [ $(cat /sys/class/power_supply/BAT1/power_now)  == 0 ]; then
  awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT0/power_now
else
  awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT1/power_now
fiprint $1*10^-6 " W"}' /sys/class/power_supply/BAT1/power_now
fi
  • Related