From 4c615d6167ba29b8820d628eba4ad8abbbe43158 Mon Sep 17 00:00:00 2001 From: Thomas Preisner Date: Fri, 2 Mar 2018 13:15:24 +0100 Subject: [PATCH] config: barpyrus: config.py: add battery percentage/status to conky Depending on the state of the battery (discharging/charging) the color and the battery icon will change. --- config/barpyrus/config.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/config/barpyrus/config.py b/config/barpyrus/config.py index 8611109..0f49e1a 100644 --- a/config/barpyrus/config.py +++ b/config/barpyrus/config.py @@ -69,6 +69,37 @@ conky_text += '${acpitemp}°C ' conky_text += conky_icon('\ue026', 'green') + '${cpu}% ' conky_text += conky_icon('\ue021', 'green') + '${memperc}% ' +# battery display +bat_icons = [ + '\ue242', '\ue243', '\ue244', '\ue245', '\ue246', + '\ue247', '\ue248', '\ue249', '\ue24a', '\ue24b', +] +bat_delta = 100 / len(bat_icons) + +conky_text += '${if_existing /sys/class/power_supply/BAT0}' +conky_text += '${if_match \"$battery\" == \"discharging $battery_percent%\"}' +for i, icon in enumerate(bat_icons[:-1]): + percentage = (i + 1) * bat_delta + conky_text += '${if_match $battery_percent < %d}' % (percentage) + if percentage <= 20: + conky_text += conky_icon(icon, 'red') + elif percentage <= 65: + conky_text += conky_icon(icon, 'yellow') + else: + conky_text += conky_icon(icon, 'green') + conky_text += '${else}' +# 100 percent icon +conky_text += conky_icon(bat_icons[-1], 'green') +# close all previously opened if_match tags +for _ in bat_icons[:-1]: + conky_text += '${endif}' +conky_text += '${else}' +conky_text += conky_icon('\ue239', 'cyan') +conky_text += '${endif}' +conky_text += ' $battery_percent% ' +conky_text += '${endif}' +conky_text += '%{F-}' + # options for hlwm.HLWMLayoutSwitcher widget xkblayouts = [ 'us us -variant altgr-intl us'.split(' '),