← Back to blog

Battery blocklet for i3blocks

Official battery blocklets from i3blocks-contrib did not work properly for me so I decided to create my own

I am a huge fan of Linux and of tile window manager named i3. For bar I've used native i3bar with conky, but it had some disadvantages like inability to handle mouse clicks. For a last week I decided to move to i3blocks, which has block structure, called blocklets. By default it has quite lot of blocklets and also there is official blocklet repository https://github.com/vivien/i3blocks-contrib and users can choose blocklets there for almost any taste. But for some reason default battery blocklet and any of stored in i3blocks-contrib didn't work as needed in my machine. I have seen incorrect % or time estimation. After some investigation I found that in my machine acpi command returns up to 3 batteries in some cases. One of them is a laptop battery, another is a Logitech mouse when connected and third one somehow showed monitor connected over usb-c. And the worst thing that laptop battery didn't have always same number(position). So if I mouse is not connected then it had nr.0, when connected - nr.1

So I decided to create my own blocklet. I checked code of all existing battery blocklets, especially battery2 https://github.com/vivien/i3blocks-contrib/tree/master/battery2 which was written in python. I am not a python developer, but it seems quite simple to understand and after some tries + googling I could create my own blocklet.

betterBattery blocklet for i3blocks

  • it uses upower console command which returns only laptop battery
  • has nice colored icons which show plugged-in/charging/discharging state and battery capacity
  • shows time until battery gets fully charged or discharged


  • upower
  • python3
  • FontAwesome font