From 3529e172bf79260ab0a6ce0d2ea9cf9da89eb440 Mon Sep 17 00:00:00 2001 From: Bartek Stalewski Date: Thu, 13 Apr 2023 23:52:59 +0200 Subject: [PATCH] Back to custom sb-battery script. --- _desktop/_scripts/sb-battery | 17 +++++++++++++++++ _desktop/qtile/config.py | 12 ++---------- 2 files changed, 19 insertions(+), 10 deletions(-) create mode 100755 _desktop/_scripts/sb-battery diff --git a/_desktop/_scripts/sb-battery b/_desktop/_scripts/sb-battery new file mode 100755 index 0000000..dd95d29 --- /dev/null +++ b/_desktop/_scripts/sb-battery @@ -0,0 +1,17 @@ +#!/bin/bash + +for battery in /sys/class/power_supply/BAT?*; do + # If non-first battery, print a space separator. + [ -n "${capacity+x}" ] && printf " " + # Sets up the status and capacity + case "$(cat "$battery/status")" in + "Full") status="\uf102" ;; + "Discharging") status="\uf078" ;; + "Charging") status="\uf077" ;; + "Not charging") status="\uf444"; exit 0 ;; + "Unknown") status="\uf128" ;; + esac + capacity=$(cat "$battery/capacity") + # Will make a warn variable if discharging and low + [ "$capacity" -le 20 ] && printf "${status} ${capacity}%%" || printf "${status} ${capacity}%%" +done && exit 0 diff --git a/_desktop/qtile/config.py b/_desktop/qtile/config.py index 378c0cb..8759bde 100644 --- a/_desktop/qtile/config.py +++ b/_desktop/qtile/config.py @@ -166,17 +166,9 @@ screens = [ update_interval=1, cmd="sb-network", ), - widget.Battery( - format='{char} {percent:2.0%}', - charge_char='\uf077', - discharge_char='\uf078', - unknown_char='\uf444', - full_char='\uf102', + widget.GenPollCommand( update_interval=1, - hide_threshold=0.8, - low_background='#770000', - low_foreground='#feffff', - low_percentage=0.2, + cmd="sb-battery", ), widget.Clock( format='[%d] %H:%M:%S',