You are not logged in.

#1 2008-06-07 00:57:31

F
Member
Registered: 2006-10-09
Posts: 322

dzen + dwm help

Hi guys, I have several dzen scripts I like but they are all seperate scripts and I don't know how to integrate them well with dwm.

The only thing I can think of is running each of the scripts so i have several instances of dzen2 running simultaneously. I know this is a very crappy idea. I'm not very good at bash/sh scripting and o i have no idea how to put all this in one script so I only have to run dzen2 once. Furthermore, i want this to be started when I start dwm. I'm not sure how to go about doing that, either.

Here are the scripts I want running:

#!/bin/sh

FG='gray70'
BG='#000000'
FONT='-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*'

while true ; do
    dt=`date +"%a %b %d %l:%M %p "`
    printf "%s\n" "$dt"
#    sleep 20
done | dzen2 -e '' -x '1124' -h '14' -w '150' -ta r -fg $FG -bg $BG -fn $FONT
#!/bin/sh
gcpubar -fg '#aecf96' -bg gray40 -h 7 -w 75 | dzen2 -ta l -w 140 -bg '#000000' -fg 'grey70' -fn '-*-terminus-*-*-*-*-12-*-*-*-*-*-iso8859' -x 995 -e ''
#!/bin/sh
# Disk usage monitor using dzen
# needs gawk
# (c) Tom Rauchenwald
 
FN='-xos4-terminus-*-*-*-*-12-*-*-*-*-*-*-*' # font
BG='#000000'  #dzen background
FG='#888888'  #dzen foreground
W=200         #bar width
X=795        #x position
#Y=768         #y position
GH=7          #gauge height
GW=50         #gauge width
GFG='#a8a3f7' #gauge color
GBG='#333'    #gauge background
 
gawk "
BEGIN {
    CMD=\"gdbar -w $GW -h $GH -fg '$GFG' -bg '$GBG'\"
    while(1) {
        i=1
        while ((\"df | grep "\/dev\/" | grep -v shm\" | getline ) > 0)
        { if (\$0 ~ /^\//) {
                print \$5 |& CMD
                CMD |& getline lin
                if (i == 1)
                    print \"^cs()\\n^tw()\", \$6, lin
                else
                    print \$6, lin, \"  \"
                i++
                close(CMD)
            }
        }
        close(\"df\")
        system(\"sleep 5\")
    }
}" | dzen2 -ta c -sa r -l 2 -w $W -tw $W -x $X -fg $FG -bg $BG -fn $FN -e "button1=togglecollapse;button3=exit"
#!/bin/sh

# icons
ICONPATH=/home/f/code/scripts/dzen/dzen_bitmaps
# font
FONT='-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*'
# network interface
INTERFACE=wlan0
# update every x seconds
SLEEP=1

# Here we remember the previous rx/tx counts
RXB=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes`
TXB=`cat /sys/class/net/${INTERFACE}/statistics/tx_bytes`

while :; do

    # get new rx/tx counts
    RXBN=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes`
    TXBN=`cat /sys/class/net/${INTERFACE}/statistics/tx_bytes`

    # calculate the rates
    # format the values to 4 digit fields
    RXR=$(printf "%4d\n" $(echo "($RXBN - $RXB) / 1024/${SLEEP}" | bc))
    TXR=$(printf "%4d\n" $(echo "($TXBN - $TXB) / 1024/${SLEEP}" | bc))

    # print out the rates with some nice formatting
    echo "${INTERFACE}: ^fg(white)${RXR}kB/s^fg(#80AA83)^p(3)^i(${ICONPATH}/arr_down.xbm)^fg(white)${TXR}  kB/s^fg(orange3)^i(${ICONPATH}/arr_up.xbm)^fg()"

    # reset old rates
    RXB=$RXBN; TXB=$TXBN

    sleep $SLEEP
done | dzen2 -bg '#000000' -w 200 -fn $FONT -x 620
#!/bin/bash
# little dzen-thingy to control your volume
# you need amixer (or aumix) and gdbar
# (c) 2007 Tom Rauchenwald and Jochen Schweizer
 
BG='#000'     # dzen backgrounad
FG='#888'     # dzen foreground
W=150         # width of the dzen bar
GW=50         #  width of the volume gauge
GFG='#a8a3f5' # color of the gauge
GH=7          # height of the gauge
GBG='#333'    # color of gauge background
X=480         # x position
#Y=786         # y position
# Caption of the gauge
# in this case it displays the volume icon shipped with dzen
CAPTION="^i(/home/f/code/scripts/dzen/dzen_bitmaps/volume.xbm) "
# Font to use
FN='-xos4-terminus-*-*-*-*-12-*-*-*-*-*-*-*'
 
# command to increase the volume
CI="amixer -c0 sset PCM 5dB+ >/dev/null"
#CI="aumix -v +5"
# command to decrease the volume
CD="amixer -c0 sset PCM 5dB- >/dev/null"
#CD="aumix -v -5
 
# command to pipe into gdbar to display the gauge
# should print out 2 space-seperated values, the first is the current
# volume, the second the maximum volume
MAX=`amixer -c0 get PCM | awk '/^  Limits/ { print $5 }'`
#MAX=100
CV="amixer -c0 get PCM | awk '/^  Front Left/ { print \$4 \" \" $MAX }'"
#CV="aumix -q | line | cut -d \" \" -f 3"
 
while true; do
    echo -n $CAPTION
    eval "$CV" | gdbar -h $GH -w $GW -fg $GFG -bg $GBG
    sleep 1;
done | dzen2 -ta c -tw $W -x $X -fg $FG -bg $BG -e "button3=exit;button4=exec:$CI;button5=exec:$CD" -fn $FN

Any help would be appreciated.

Offline

#2 2008-06-07 02:44:05

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: dzen + dwm help

If you want the output to be combined; shown in one line, in one dzen, put the stuff in the while loop you want into one while loop whose results are piped to one dzen (the done | dzen2 ...)

If they are supposed to be aligned to different spots on the screen, you need to use separate dzens (unless something has changed in the past 6 months, when I last looked at dzen)

Offline

Board footer

Powered by FluxBB