From 40ce35bd2f379f2c30e51173752926f8c620ffd6 Mon Sep 17 00:00:00 2001 From: Andrew Guschin Date: Mon, 10 May 2021 14:44:07 +0400 Subject: Changed window manager to bspwm and added custom config for lemonbar --- .local/bin/lemonbar/modules/battery.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .local/bin/lemonbar/modules/battery.py (limited to '.local/bin/lemonbar/modules/battery.py') diff --git a/.local/bin/lemonbar/modules/battery.py b/.local/bin/lemonbar/modules/battery.py new file mode 100644 index 0000000..cb93f03 --- /dev/null +++ b/.local/bin/lemonbar/modules/battery.py @@ -0,0 +1,11 @@ +def read_file(filename): + with open(filename) as f: + return f.read().strip() + +def callback(): + battery = "BAT0" + now = int(read_file(f"/sys/class/power_supply/{battery}/energy_now")) + full = int(read_file(f"/sys/class/power_supply/{battery}/energy_full")) + percent = round(now / full * 100) + return f"BAT: {percent}%" + -- cgit v1.2.3