Skip to content

hujberhunor/polybar-thinkpad-battery

Repository files navigation

ThinkPad Battery Status for Polybar

A Polybar module for monitoring ThinkPad batteries, dynamically handling multiple battery systems, displaying charge status, and providing a Rofi-based menu for detailed information.

Battery Full Battery Discharging

About the Repository

This is my first project.
I’m new to GitHub and bash scripting, and I created this script with my current knowledge and some assistance from ChatGPT to solve a problem I couldn’t find a solution for.
Tested only on a ThinkPad T480.

UPDATE

Now updated with a battery alert script that sends a notification when one of the 2 battery is under 7%. Notification depends on notify-send.

Screenshots

  • Battery at Full Capacity (White LED on port)

    at-full

  • Unplugged and Discharging (No LED on port)

    discharge

  • Charging (Red LED on port)

    charging

  • Left Click Module Display

    rofi

Features

  • Calculates the weighted average of battery charge based on capacity (24Wh, 48Wh, or 72Wh)
  • Displays charge status (charging, discharging, AC power) and current power consumption
  • A single click opens a Rofi-based menu with detailed battery information
  • Automatically detects and adjusts for battery swaps (e.g., switching between 24Wh and 72Wh)

Dependencies

  • acpi (to check battery status)
  • rofi (for the clickable menu)
  • Nerd Fonts or Awesome Fonts (for icons)

** **Installation

  1. Copy the scripts to an accessible location, e.g.:
mkdir -p ~/.config/polybar
cp bat-status-bar.sh bat-dropdown-rofi.sh ~/.config/polybar/
  1. Add the following to your Polybar configuration (~/.config/polybar/config.ini):
[module/battery]
type = custom/script
exec = ~/.config/polybar/bat-status-bar.sh
click-left = ~/.config/polybar/bat-dropdown-rofi.sh
interval = 10
  1. Update the Rofi theme in bat-dropdown-rofi.sh if necessary:
rofi -show run -theme ~/.config/polybar/batteries_rofi_style.rasi

If you prefer a custom theme, edit the corresponding .rasi file.

Rofi Theme

The Rofi theme is based on @adi1090x. If you prefer a custom theme, modify the batteries_rofi_style.rasi file!


Note: I don’t own the Rofi style configuration; it’s credited to @adi1090x, and credentials are included in the file.

About

Polybar script/module that can handle 2 battery

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages