Bar / Conky Configs. - Desktop Customization & Workflow

Users browsing this thread: 7 Guest(s)
pvtmert
Members
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------


Messages In This Thread
Bar / Conky Configs. - by jmbi - 07-08-2012, 10:48 PM
RE: Bar / Conky Configs. - by yrmt - 08-08-2012, 01:02 PM
RE: Bar / Conky Configs. - by Jayro - 08-08-2012, 02:00 PM
RE: Bar / Conky Configs. - by DotDev - 17-08-2013, 07:28 PM
RE: Bar / Conky Configs. - by zygotb - 18-08-2013, 05:36 AM
RE: Bar / Conky Configs. - by funriz - 19-01-2014, 06:03 AM
RE: Bar / Conky Configs. - by rudylorren - 22-02-2014, 02:53 AM
RE: Bar / Conky Configs. - by lidstah - 21-01-2014, 11:43 AM
RE: Bar / Conky Configs. - by earsplit - 21-01-2014, 09:41 PM
RE: Bar / Conky Configs. - by berk - 23-01-2014, 05:57 PM
RE: Bar / Conky Configs. - by cyberpunkz - 12-02-2014, 03:03 AM
RE: Bar / Conky Configs. - by venam - 12-02-2014, 03:26 AM
RE: Bar / Conky Configs. - by cyberpunkz - 12-02-2014, 03:31 AM
RE: Bar / Conky Configs. - by yrmt - 12-02-2014, 08:00 AM
RE: Bar / Conky Configs. - by cyberpunkz - 12-02-2014, 11:54 AM
RE: Bar / Conky Configs. - by cyberpunkz - 12-02-2014, 08:23 PM
RE: Bar / Conky Configs. - by cyberpunkz - 13-02-2014, 02:04 AM
RE: Bar / Conky Configs. - by yrmt - 13-02-2014, 04:17 AM
RE: Bar / Conky Configs. - by cyberpunkz - 13-02-2014, 09:15 AM
RE: Bar / Conky Configs. - by yrmt - 13-02-2014, 09:37 AM
RE: Bar / Conky Configs. - by funriz - 23-02-2014, 02:55 AM
RE: Bar / Conky Configs. - by kirby - 11-07-2014, 01:53 PM
RE: Bar / Conky Configs. - by dcli - 11-07-2014, 02:40 PM
RE: Bar / Conky Configs. - by kirby - 11-07-2014, 03:45 PM
RE: Bar / Conky Configs. - by pvtmert - 15-07-2014, 05:12 PM
RE: Bar / Conky Configs. - by kirby - 16-07-2014, 11:45 AM
RE: Bar / Conky Configs. - by pvtmert - 20-07-2014, 03:37 PM
RE: Bar / Conky Configs. - by neeasade - 05-04-2015, 06:13 PM
RE: Bar / Conky Configs. - by seninha - 05-05-2020, 08:42 PM
RE: Bar / Conky Configs. - by neeasade - 05-05-2020, 08:50 PM
RE: Bar / Conky Configs. - by z3bra - 07-05-2020, 08:17 AM
RE: Bar / Conky Configs. - by Wildefyr - 07-05-2020, 10:42 AM
RE: Bar / Conky Configs. - by neeasade - 07-05-2020, 11:53 AM
RE: Bar / Conky Configs. - by sth - 10-05-2020, 05:46 PM
RE: Bar / Conky Configs. - by yakumo.izuru - 22-04-2022, 09:51 AM