Super hacky shell wrapper around lemonbar that aims to poll as little as possible, minimising bar updates to the screen and reduce resource usage.
git clone https://mcol.xyz/code/lemontools
Log | Files | Refs | README | LICENSE

commit 634157884384a20e6909523f8f5687429b2cb95c
parent cbf74da4d5489a6031370317086a80b31308c24f
Author: mcol <mcol@posteo.net>
Date:   Wed, 20 Feb 2019 20:40:50 +0000

cpu module use standard format string to produce output;

Diffstat:
Mmodules/cpu | 37++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/modules/cpu b/modules/cpu @@ -7,44 +7,43 @@ # Settings: # $cpu_bars : boolean, false will show percentage, true (default) will show # bars -# $cpu_bg : background colour for module -# $cpu_fg : foreground colour for module # $cpu_refresh : number of seconds to wait between refreshing value +# $cpu_format : format string of output where $cpu_val is the cpu usage as +# percentage or bar (Default: '$cpu_val') _cpu() { get_clicks cpu - local output + local cpu_val local prev_cpu_val local cpu_args - [[ -z "$cpu_bg" ]] && cpu_bg=$background - [[ -z "$cpu_fg" ]] && cpu_fg=$foreground + [[ -z "$cpu_format" ]] && + cpu_format='$cpu_val' + + [[ -z "$cpu_bars" ]] && + cpu_bars=true - if ${cpu_bars:-true} - then + ${cpu_bars} && cpu_args=-b - fi - if [[ -n "$cpu_refresh" ]] - then + [[ -n "$cpu_refresh" ]] && cpu_args="$cpu_args -t $cpu_refresh" - fi $dir/modules_c/cpu $cpu_args | while read cpu_val do [[ $cpu_val == $prev_cpu_val ]] && continue prev_cpu_val=$cpu_val - [[ $cpu_val -lt 10 ]] && cpu_val=" $cpu_val" - output=${pad}${cpu_prefix}${cpu_val}${cpu_suffix}${pad} - output=%{F$cpu_fg}%{B$cpu_bg}${output}%{B-}%{F-} - output=${cpu_pre}${output}${cpu_post} - send "cpu='$output'" + + if ! ${cpu_bars} && [[ $cpu_val -lt 10 ]] + then + # pad out single digit + cpu_val=" $cpu_val" + fi + + send "cpu='$(eval echo ${cpu_pre}${cpu_format}${cpu_post})'" done & } - # vim: ft=sh - -