funriz
kirby
I'm using bar for the first time and although I have it looking nice (though not finished, still need the desktops), I've clearly done something wrong. Every time it updates, it just creates a new instance on top of the old one, and this quickly fills up the resource limit on X (I didn't even know X had a resource limit). My script for the bar is here. What do I do to fix this issue?
dcli
Updates how, kirby? Like every time the clock changes?
kirby
Every second, it's a loop with 'sleep 1' at the end. You can see how this would really quickly fill up the limit.
pvtmert
kirby, pipe bar after 'done' also you can use while sleep 1; do
something something
echo something | tr -d \\n #trim newline for actually viewing output
done | bar -p #something else

this is my current bar script:
Code:
#!/bin/bash

SLP=1
BG=\#de002b36
FG=\#de839496
PX=1
FT="-*-terminus-medium-r-normal-*-12-*"

{ #looknfeel
    OPACITY=85
    BACKGROUND=232c31
    FOREGROUND=c5c8c6
    COLOR0=2d3c46
    COLOR1=ac4142
    COLOR2=90a959
    COLOR3=de935f
    COLOR4=6a9fb5
    COLOR5=aa759f
    COLOR6=75b5aa
    COLOR7=6c7a80
    COLOR8=425059
    COLOR9=cc6666
}


makecolor()
{
    echo $(printf "#%x%s" $((OPACITY*255/100)) "$1")
}

{ #GLOB VARS
    USER=$(whoami)
    GRP=$(id -g)
    HOST=$(hostname)
    DOMAIN=$(domainname)
    BATF="/sys/class/power_supply/BAT1/capacity"
    LDAVGF="/proc/loadavg"
    # static colors:
    USRC=\#ff000000
    DATEC=$(makecolor $COLOR3)
    test $GRP -eq 0 && USRC=darkred
    test $GRP -eq 2 && USRC=yellow
    test $GRP -eq 4 && USRC=maroon
    test $GRP -eq 3 && USRC=gray
    test $GRP -eq 5 && USRC=black
    test $GRP -eq 29 && USRC=green
    LDAVGC=$(makecolor $COLOR6)
    DESKCL=$(makecolor $COLOR1)
    FG=$(makecolor $FOREGROUND)
    BG=$(makecolor $BACKGROUND)
}

NAT=`hostname`
while sleep $SLP; do
    test $(($(date +%s)%20)) -eq 0 && NAT=$(curl --connect-timeout $((SLP*2)) -s icanhazip.com || echo "(no-*net)")
    echo
    {
        INET=$(ifconfig | grep inet | grep -v inet6 | grep -v 127.0.0.1 | cut -d\  -f10 | tr \\n '|')
        BATS=$(cat $BATF)
        BATC=gray
        test $BATS -gt 80 && BATC=green
        test $BATS -lt 40 && BATC=yellow
        test $BATS -lt 20 && BATC=red
        BAT=$(printf "%3d" $BATS)
        LOADAVG=$(cat $LDAVGF | cut -d\  -f1-3)
        DESKC=$(xprop -root _NET_CURRENT_DESKTOP | sed -e 's/_NET_CURRENT_DESKTOP(CARDINAL) = //')
        test $DESKC -eq 0 && DESKB=9 || DESKB=$((DESKC-1))
        test $DESKC -eq 9 && DESKA=0 || DESKA=$((DESKC+1))
        # sep
        echo "%{c}%{+o}%{U-}"
        echo " < %{U$LDAVGC}%{A:xterm -e htop &:}$LOADAVG%{A}%{U-} > "
        echo " < %{U$BATC}%{A:xterm -e powertop &:}BAT: $BAT%%%{A}%{U-} >"
        echo " < %{U$DATEC}%{A:xclock &:}$(date +'%A, %Y-%m-%d | %H:%M:%S')%{A}%{U-} > "
        echo " < $DESKB |%{U$DESKCL} $DESKC %{U-}| $DESKA > "
        echo " < %{U$USRC}%{A:systemsettings &:}$USER@$INET$NAT%{A}%{U-} > "
    } | tr -d \\n | tr -s \
done | bar -u$PX -F$FG -B$BG -f$FT -d

exit 0

and this is prev. one

Code:
#!/bin/bash

WIDTH=170
WIDTH=$((170-15))
SW=31
SLP=1.5
SEP=" | "

for i in 0 1 2 3; do sleep $SLP; done
{ #glob vars
    batd=/sys/class/power_supply/BAT1/
    min=$((0))
    if [ "$WM" == "twm" ]; then
        min=$((1))
        desk=($(printf "9\n"; vdesk))
        max=$((${desk[0]}))
    else
        min=$((0))
        #desk=$(xprop  -root  _NET_CURRENT_DESKTOP|  sed  -e 's/_NET_CURRENT_DESKTOP(CARDINAL) = //')
        desk=($(xprop -root | grep -i cardinal | grep -i desktop | grep -iv "xprop\|grep\|cut" | cut -d\= -f2 | cut -b 2-))
        max=$((${desk[0]} - 1))
    fi
    i=0
    who=`whoami`
    host=`hostname`
    dom=`domainname | sed 's/\./[dot]/g'`
    user="mert"
    text=("`swapon -s | tail -n1 | tr -s ' ' | sed 's/\t/ /g' | cut -d\  -f1,2,3,4 | cut -b -$((SW-3))`"
          "\f6`uname -mroi | tr -s ' ' | cut -b -$SW`\fr"
          "`date | cut -b -$SW`"
          "`uptime | cut -b -$SW`"
          "`echo \"$user: $who[at]$dom\" | cut -b -$SW`" )
    #`printf "$user: $who[at]$dom" | cut -b -$SW`
}

while true; do
{
    text[2]="\\u3`date +\"%A, %Y-%m-%d ¦ %H:%M:%S\" | cut -b -$SW`\\ur"
    text[3]="\\u4`uptime | cut -d, -f1,2,3 | sed 's/\t/ /g' | tr -s ' ' | sed 's/load average:/load:/g' | cut -d\  -f3,4,5,6,7,8,9 | rev | cut -b 1- | rev | cut -b -$SW`\\ur"

    #batf=$(cat $batd/energy_full)
    #batn=$(cat $batd/energy_now)
    #bats=$(( 100 * batn / batf ))
    bats=$(cat $batd/capacity)

    ups=$(cat /proc/uptime | cut -d\  -f1 | cut -d. -f1)
        days=$((ups/(60*60*24)))
            ups=$((ups-days*60*60*24))
        hrs=$((ups/3600))
            ups=$((ups-hrs*3600))
        mins=$((ups/60))
            ups=$((ups-mins*60))
        text[0]=$(printf "\\\u6 Bat: % 3d%% \\\ur ¦ Up: %02dd %02dh %02dm %02ds" ${bats} ${days} ${hrs} ${mins} ${ups} )
        text[0]=$(printf "%*s" $SW "${text[0]}")
        text[3]="\\u4 load avg: `cat /proc/loadavg | cut -d\  -f1,2,3` \\ur"

    if [ "$WM" == "twm" ]; then
        desk=($(printf "9\n"; vdesk))
    else
        desk=($(xprop -root | grep -i cardinal | grep -i desktop | grep -iv "xprop\|grep\|cut" | cut -d\= -f2 | cut -b 2-))
    fi

    printf "\n\l ! \c"
    for i in {0..3}; do
    { #Sections
        printf "%-*s" $SW "${text[$i]}"
    }; printf "$SEP"; done
    #i=$((i+1)); printf "%-*s\\\r ! " $((SW-3)) "${text[$i]}"
    for ((i=${desk[1]}-3;i<${desk[1]}+4;i++)); do
        if [ "$i" == "${desk[1]}" ]; then
            printf '\\\\\\u1 %d \\\\\\ur' $i
        elif [ $i -lt $min ]; then
            printf " $((i+${desk[0]})) "
        elif [ $i -gt $max ]; then
            printf " $((i-${desk[0]})) "
        else
            printf " $i "
        fi
    done | { read x; printf "%*s  ¦ %*s" $((SW-${#who}-1)) "$x" $((SW-${#x})) "$who" ; }
    printf "\\\r ! "
}; sleep $SLP; done | /usr/bin/bar -pfl

exit 0

Code:
Slax 7.0.8 (32-bits + PAE)
----- BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE/CS/CM/S d+@ s-:- a--- C++++(++) UL+++ P+ L+++ E?() W+++(++) N? o? K- w+
O M-- V- PS+ PE Y? PGP- t+ 5? X++++(+++) R- !tv b+ DI? D- G e- h+ r-- z--
------END GEEK CODE BLOCK------
kirby
(15-07-2014, 05:12 PM)pvtmert Wrote: kirby, pipe bar after 'done' also you can use while sleep 1; do
something something
echo something | tr -d \\n #trim newline for actually viewing output
done | bar -p #something else

I'm not entirely sure I understand what's going on here, and can't get it to work myself. How do you get the bar to see what's being echo'd? If I end in

Code:
tr -s /
done | bar

I get 'Unexpected end of file'. You know you can use 'echo -n' to get rid of the newline right?
pvtmert
backslash is important, i used to squeeze spaces into one...
you got it about echo -n

you have to pipe to bar 'after' all output. you can think as while never prints eof so bar will stay open and being refreshed.

all you have to do is
while sleep $((SLEEP));
do
echo -n "hello world"
done | bar #args
neeasade
Here is my bar configuration:

[Image: xrnris.png]

The smaller squares are workspaces, and the larger on on the end is a tiling/monocle mode indicator. If in monocle mode, the bar turns into clickable title text for windows in the workspace:

[Image: ymlffx.png]

and a link to it's configuration!: link
phillbush
What is the difference between lemonbar and dzen2? What can I do with dzen2 that I cannot do with lemonbar (and vice-versa)?
neeasade
> What can I do with dzen2 that I cannot do with lemonbar

dropdowns/the notion of a 'heading' on dropdowns. personally I think the lemonbar experience is "cleaner" wrt constructing sections with settings (I made a small helper for it).


Speaking of necrobumps, I recently updated my own panel configuration -- I now use i3blocks to drive lemonbar, through jq. See the madness here. i3blocks generates _a lot_ of output, so I debounce it. I still use a theming system to generate my i3blocks config -- here's an example of what an i3blocks config might look like: https://0x0.st/i262.txt . The 'season' script is responsible for theme ideas around panel sections.




Members  |  Stats  |  Night Mode