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 63923dfc66f37edd03c45f0fe2d67e44af3fb8a2
parent be539638bb42a3de21372763c286af4275806733
Author: mcol <mcol@posteo.net>
Date:   Thu,  3 Jan 2019 23:06:09 +0000

cleaned up some lines

Diffstat:
Mstart-lemonbar | 48+++++++++++++++++++++++++-----------------------
1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/start-lemonbar b/start-lemonbar @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/bin/bash # # ___ _______ __ __ _______ __ _ _______ _______ ______ # | | | || |_| || || | | || _ || _ || _ | @@ -14,8 +14,23 @@ # Helper functions ##---------------------------------------------------------------------------------- +print_help() { + cat << EOF + start-lemonbar: lemonbar helper script + Usage: + -h Display this help message + -l List modules + -T List themes + -t <theme> Run with specified theme (defaults to theme + specified by the X resource 'wm.bartheme' + -f <path> Run with specified fifo file + -k Kill all lemonbar instances +EOF +exit 0 +} + + kill_lemonbar() { - # shutdown any running instances for program in lemonbar start-lemonbar.sh do pkill -f $program @@ -24,21 +39,19 @@ kill_lemonbar() { [ -e $fifo ] && rm $fifo } + start_feed() { # this listens to $fifo and constructs the output - #num_fields=1 while read -r line ; do final_output= output= eval $line # £ in $line delimits outputs per monitor - if echo "$line" | grep -q "£" + if grep -q "£" <<< "$line" then this_module=$(awk -F '=' '{print $1}' <<< "${line}") - #num_fields=$(awk -F '£' '{print NF}' <<< "${!this_module}") fields=() - #for ((s=1; s<=num_fields; s++)) for ((s=1; s<=num_monitors; s++)) do fields+=("$(awk -F '£' -v x=$s '{print $x}' <<< "${!this_module}")") @@ -76,7 +89,6 @@ start_feed() { final_output="${final_output}${this_output}" done - #num_fields=1 echo $final_output | sed "s/PAD/ /g" | sed "s/bspwm_gap/ /g" else # pipe to bar via echo @@ -91,8 +103,8 @@ start_bar() { printf "Lemonbar started.\n" start_feed | $bar | while read msg do - # execute outputs from bar - $msg & + # execute outputs from bar, logging to $logfile + $msg &> $logfile & done } @@ -107,24 +119,15 @@ dir=$(dirname $(readlink -f $0)) # Modules modules_file=$dir/modules -# if theme is specified manually -theme_specified=false +# logfile for commands output from lemonbar +logfile="/tmp/lemonerror" # fifo file fifo="/tmp/lemonbar" while getopts ":hlTt:f:k" arg; do case $arg in - h) printf "\nstart-lemonbar.sh: lemonbar helper script - Usage: - -h Display this help message - -l List modules - -T List themes - -t <theme> Run with specified theme (defaults to theme - specified by the X resource 'wm.bartheme' - -f <path> Run with specified fifo file - -k Kill all lemonbar instances\n\n" - exit 0 + h) print_help ;; l) printf "Available modules:\n" @@ -150,6 +153,7 @@ while getopts ":hlTt:f:k" arg; do esac done +[[ -z $theme_specified ]] && theme_specified=false #---------------------------------------------------------------------------------- # Run @@ -192,9 +196,7 @@ do done # start bar -#start_feed start_bar - # vim: filetype=sh