You are not logged in.

#51 2007-12-19 22:50:24

tizoc
Member
Registered: 2006-07-28
Posts: 57

Re: dzen & xmobar Hacking Thread

gotmor wrote:

Hello,

I'm just writing to inform you that dzen's wiki has moved to:

    http://dzen.geekmode.org/wiki/wiki.cgi/-main/

Wow, I was browsing the wiki and noticed that there was an entry named DzenSchemeMonitor, and with curiosity I clicked on the link to see how it compared to the one I made some time ago to use with dzen2 in my macbook.... I laughed when I found out it was the one I made lol

I don't even remember when I pasted it on a pastebin!

Btw, I don't find Scheme to be more exotic than Haskell smile

An slightly updated version is here:

(use srfi-13)
(use srfi-1)
(use gauche.process)

;; = Config =
(define DATE-FORMAT "'%A, %d.%m.%Y %H:%M:%S'")
(define DZEN-ICONPATH "/home/bruno/.config/dzen2/bitmaps")

;; Appareance
(define FONT "'-*-profont-*-*-*-*-11-*-*-*-*-*-iso8859'")
(define BACKGROUND-COLOR "'#2c2c32'")
(define ALTERNATE-BACKGROUND-COLOR "'#494b4f'")
(define FOREGROUND-COLOR "'grey70'")
(define SEPARATOR "^p(3)^r(3x3)^p(3)")

;; Cpu settings
(define CPU-CORES (list 0 1))

;; Main loop interval in seconds
(define SLEEP-INTERVAL 1)

;; Utils
(define (for-each-line-from-port proc port)
  (call-with-current-continuation
   (lambda (break)
     (let loop ((line (read-line port)))
       (cond
        ((eof-object? line))
        ((proc line break) (loop (read-line port)))
        (else (loop (read-line port))))))))

(define (call-for-each-line-in-file filename proc)
  (call-with-input-file filename
    (lambda (port)
      (for-each-line-from-port proc port))))

(define (call-for-each-line-in-pipe command proc)
  (call-with-input-process command
    (lambda (port)
      (for-each-line-from-port proc port))))

(define (read-last-available-line)
  (if (char-ready?)
      (let ((line (read-line)))
        (or (read-last-available-line) line))
      #f))

;; Cpu Load
(define *CPU-STATS* (make-vector (length CPU-CORES) (list 0 0 0 0 0)))
(define *CPU-LOADS* (make-vector (length CPU-CORES) 0.0))

(define (update-cpu-loads)
  (call-for-each-line-in-file "/proc/stat"
    (lambda (line break)
      (if (string= line "cpu" 0 3)
          (let* ((tokens (string-tokenize line))
                 (core (string->number (substring/shared (car tokens) 3))))
            (if (and core (memv core CPU-CORES))
                (let* ((oldstat (vector-ref *CPU-STATS* core))
                       (newstat (map string->number (take (cdr tokens) 5)))
                       (diffs (map - newstat oldstat))
                       (total (/ (fold + 0 diffs) 100.0))
                       (idle-diff (list-ref diffs 3))
                       (cpu-load (/ (fold + (- idle-diff) diffs) total)))
                  (vector-set! *CPU-STATS* core newstat)
                  (vector-set! *CPU-LOADS* core cpu-load))))))))

;; Cpu Temperature
(define *CPU-TEMPERATURES* (make-vector (length CPU-CORES) 0))

(define (update-cpu-temperatures)
  (define (update-temperature n)
    (call-with-input-file (string-append "/sys/devices/platform/coretemp."
                                         (number->string n)
                                         "/temp1_input")
      (lambda (port)
        (let ((temperature (/ (string->number (read-line port)) 1000)))
          (vector-set! *CPU-TEMPERATURES* n temperature)))))
  (for-each update-temperature CPU-CORES))


;; Battery status
(define *BATTERY-STATUS* "")

(define (update-battery-status)
  (call-for-each-line-in-file "/proc/acpi/battery/BAT0/state"
    (lambda (line break)
      (if (string-prefix? "charging state" line)
          (let ((status-string (list-ref (string-tokenize line) 2)))
            (set! *BATTERY-STATUS* status-string)
            (break))))))

;; Battery charge
(define *BATTERY-CHARGE* 0)

(define (update-battery-charge)
  (define (get-full-capacity line break)
    (if (string-prefix? "last full capacity" line)
        (break (string->number (list-ref (string-tokenize line) 3)))))
  (define (get-remaining-capacity line break)
    (if (string-prefix? "remaining capacity" line)
        (break (string->number (list-ref (string-tokenize line) 2)))))
  (let ((full (call-for-each-line-in-file
               "/proc/acpi/battery/BAT0/info"
               get-full-capacity))
        (remaining (call-for-each-line-in-file
                    "/proc/acpi/battery/BAT0/state"
                    get-remaining-capacity)))
    (set! *BATTERY-CHARGE* (round (/ (* 100 remaining) full)))))

;; XKB map
(define *XKB-MAP* "")

(define (update-xkb-map)
  (call-for-each-line-in-pipe "setxkbmap -print"
    (lambda (line break)
      (if (string-prefix? "xkb_symbols" (string-trim line))
          (let* ((xkb-string (list-ref (string-tokenize line) 3))
                 (i (string-index xkb-string #\+))
                 (keymap (substring/shared xkb-string (+ i 1) (+ i 3))))
            (set! *XKB-MAP* keymap)
            (break))))))

;; Date
(define *DATE&TIME* "")

(define (update-date&time)
  (call-for-each-line-in-pipe (string-append "date +" DATE-FORMAT)
    (lambda (line break)
      (set! *DATE&TIME* line))))

;; Xmonad information
(define *XMONAD-INFORMATION* "")

(define (update-xmonad-information)
  (let ((line (read-last-available-line)))
    (set! *XMONAD-INFORMATION* (or line *XMONAD-INFORMATION*))))

;; Display status line
(define (display-status-line port)
  (let ((information-line (format
                           #f
                           "^bg()~3@a% (~2a°C) ~3@a% (~2a°C)~a ~3@a% ~11a ~a ~a ~a ^fg(white)~a^fg()"
                           (inexact->exact (round (vector-ref *CPU-LOADS* 0)))
                           (vector-ref *CPU-TEMPERATURES* 0)
                           (inexact->exact (round (vector-ref *CPU-LOADS* 1)))
                           (vector-ref *CPU-TEMPERATURES* 1)
                           SEPARATOR
                           *BATTERY-CHARGE*
                           *BATTERY-STATUS*
                           SEPARATOR
                           *XKB-MAP*
                           SEPARATOR
                           *DATE&TIME*)))
    (display (format #f "^bg(#494b4f)~131,,,,131:a" *XMONAD-INFORMATION*) port)
    (display information-line port)
    (newline port)))

(define (main args)
  (call-with-output-process (string-append "dzen2 -ta r -fn "
                                           FONT
                                           " -bg "
                                           BACKGROUND-COLOR
                                           " -fg "
                                           FOREGROUND-COLOR
                                           " -p -e ''")
    (lambda (port)
      (let loop ()
        (update-cpu-loads)
        (update-cpu-temperatures)
        (update-battery-status)
        (update-battery-charge)
        (update-xkb-map)
        (update-date&time)
        ;(update-xmonad-information)

        (display-status-line port)
        (sys-sleep SLEEP-INTERVAL)
        (loop)))))

Last edited by tizoc (2007-12-19 22:52:04)

Offline

#52 2007-12-19 23:38:48

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

tizoc wrote:
gotmor wrote:

Hello,

I'm just writing to inform you that dzen's wiki has moved to:

    http://dzen.geekmode.org/wiki/wiki.cgi/-main/

Wow, I was browsing the wiki and noticed that there was an entry named DzenSchemeMonitor, and with curiosity I clicked on the link to see how it compared to the one I made some time ago to use with dzen2 in my macbook.... I laughed when I found out it was the one I made lol

I don't even remember when I pasted it on a pastebin!

Hehe, very cool! So, I finnaly found the author big_smile.
I stumbled upon your code while searching google and was amazed to see a dzen driver in Scheme smile.

Btw, I don't find Scheme to be more exotic than Haskell smile

No, it's surely not more exotic, though Haskell is also not a what i would call "mainstream" language wink.

An slightly updated version is here:

So, if you find some spare time please update the wiki entry preferably with a short description and a screenshot of your code in action.

Offline

#53 2007-12-20 00:03:33

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: dzen & xmobar Hacking Thread

gotmor wrote:

So, if you find some spare time please update the wiki entry preferably with a short description and a screenshot of your code in action.

I actually updated the code already, with attribution going to tizoc... but a screenshot would be great.


thayer williams ~ cinderwick.ca

Offline

#54 2007-12-20 02:04:39

fivre
Member
Registered: 2007-04-17
Posts: 99

Re: dzen & xmobar Hacking Thread

Trying this out for the first time, albeit with fluxbox rather than xmonad or whatever. For some reason it tells me it can't load terminus, even though I do indeed have terminus-font installed.

dzen: error, cannot load font: '-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*'

Also, I've noticed that conky is still drawing to the desktop, and this is rather annoying. I notice it doesn't show up on anyone else's screenshots, is this because I'm using fluxbox? Either way, how do I get rid of it?

Configs for reference:

#conkyrc for dzen

background        no
out_to_console        yes
update_interval        1.0
total_run_times        0
use_spacer        yes    

TEXT
^fg(#AC2B2B)${pre_exec whoami}^fg(#BBBBBB)@^fg(#AC0000)$nodename^fg(#BBBBBB) :: ^i(~/.dzen/icons/cpu.xbm) ${cpu cpu1}% ${freq cpu1}MHz ${cpu cpu2}% ${freq cpu2}MHz ${acpitemp}°C :: ^i(mem.xbm) ${memperc}% :: ^i(battery.xbm) ${battery BAT1} :: ^i(arr_down.xbm) ${upspeed ath0} ^i(arr_up.xbm) ${downspeed ath0} kB/s :: ~ ${fs_used /home/fivre}/${fs_size /home/fivre}
#!/bin/sh

#Foreground and Background
FG='#BBBBBB'
BG='#000000'

#Font
FONT='-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*'

#X and Y
XCOORD=0
YCOORD=0

#SIZE
HEIGHT=20
TWIDTH=
DWIDTH=

conky -c ~/conkycli | dzen2 -e '' -x $XCOORD -y $YCOORD -h $HEIGHT -fg $FG -bg $BG -fn $FONT

Offline

#55 2007-12-20 02:12:41

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: dzen & xmobar Hacking Thread

fivre wrote:

Trying this out for the first time, albeit with fluxbox rather than xmonad or whatever. For some reason it tells me it can't load terminus, even though I do indeed have terminus-font installed.

For terminus to work, you have to add the font path to your xorg.conf:

Section "Files"
    ...
    FontPath     "/usr/share/fonts/local"        # added for Terminus
    ...
EndSection

As for conky printing to screen, are you sure you are running conky-cli (it's in the AUR)?


thayer williams ~ cinderwick.ca

Offline

#56 2007-12-20 03:46:50

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

HEADS UP. in latest SVN dzen (svn checkout http://dzen.googlecode.com/svn/trunk/ dzen)  ^r() and ^ro() accept parameters of the form "WIDTHxHEIGHT" and "WIDTHxHEIGHT±X±Y".

You can do things like vOTE5 with the new synatx..

Offline

#57 2007-12-20 04:34:26

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: dzen & xmobar Hacking Thread

purdy... thanks Rob!


thayer williams ~ cinderwick.ca

Offline

#58 2007-12-20 05:11:58

fivre
Member
Registered: 2007-04-17
Posts: 99

Re: dzen & xmobar Hacking Thread

Okay, I've fixed my previous problems, but now I can't get any images to display. Same config as before. What am I doing wrong?

Offline

#59 2007-12-20 13:52:48

cu3edweb
Member
From: USA
Registered: 2007-10-07
Posts: 291

Re: dzen & xmobar Hacking Thread

Thayer or anyone: Where did you get the marker.xbm also does anyone have icons for the tabbed, and grid layouts?

Thanks

Offline

#60 2007-12-20 14:08:07

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

cu3edweb wrote:

Thayer or anyone: Where did you get the marker.xbm also does anyone have icons for the tabbed, and grid layouts?

Thanks

Here is marker.xbm: marker.xbm
Those icons are very simple to make, I might make some more layout later.

Offline

#61 2007-12-20 14:11:50

cu3edweb
Member
From: USA
Registered: 2007-10-07
Posts: 291

Re: dzen & xmobar Hacking Thread

quarks wrote:

Here is marker.xbm: http://goox.net/joost/tmp/marker.xbm
Those icons are very simple to make, I might make some more layout later.

Thanks for the marker. I just made the ones I needed.

Offline

#62 2007-12-20 14:16:06

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

fivre wrote:

Okay, I've fixed my previous problems, but now I can't get any images to display. Same config as before. What am I doing wrong?

That config doesn't seem to have any images with their full paths, ie ^i(/path/to/bitmaps/bitmap.xbm).

dzen is going to need fully-qualified paths to each image.

If you want xpm (full-colour) support, you'll have to patch that in yourself (I posted a pkgbuild somewhere in this thread).


Cthulhu For President!

Offline

#63 2007-12-20 17:52:23

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

EDIT:
Graph support is now in the SVN version. No need for gcpubarG any more.
Check out the wiki entry for more details.

dz-grbig.png
gcpubar -fg grey50 -s graph -gw 12 -gs 1 -w 300 -h 62 -l '^i(cpuicon.xpm)' | dzen2 -h 64 -w 370 -ta l -bg black


-----------------------------------------------------------------------------

I just hacked up a first alpha version of graph support for gcpubar.

You need the latest SVN dzen version, and this modified version of gcpubar.

Compile it:

 gcc -o gcpubarG gcpubarG.c

Use it like:

 gcpubarG -i 1 -h 30 -w 120 -s 1 | dzen2 -w 120 -h 30 -ta l

Where '-s' is the amount of space in pixels between each graph value.

You can make graphs like these:
vOTIz
The upper graph runs with "-s 0", the lower with "-s 1".

Or integrate it in a statusbar:
vOTI1


Rob.

Last edited by gotmor (2007-12-22 00:19:57)

Offline

#64 2007-12-20 18:06:31

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

gotmor wrote:

I just hacked up a first alpha version of graph support for gcpubar.

You need the latest SVN dzen version, and this modified version of gcpubar.

Compile it:

 gcc -o gcpubarG gcpubarG.c

Use it like:

 gcpubarG -i 1 -h 30 -w 120 -s 1 | dzen2 -w 120 -h 30 -ta l

Where '-s' is the amount of space in pixels between each graph value.

You can make graphs like these:
http://omploader.org/vOTIz
The upper graph runs with "-s 0", the lower with "-s 1".

Or integrate it in a statusbar:
http://omploader.org/vOTI1


Rob.

Wow, that looks great!

Offline

#65 2007-12-20 18:13:08

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: dzen & xmobar Hacking Thread

Indeed, that does look great.  I must admit I'm not a fan of bars or graphs because I feel my desktop space is at a premium already, but kudos for the additional feature.


thayer williams ~ cinderwick.ca

Offline

#66 2007-12-20 21:43:14

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

Thought I'd share my dzen config I have so far.

dzen.png

Requires mocp and Rob's weather script.

#!/bin/zsh
#
# Dzen statusbar, compiled from various sources
# Requires weather.com key and mocp
##################################################################

# Configuration
##################################################################
# Dzen's font
DZENFNT="-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*"
# Dzen's background colour
DZENBG='#000000'
# Dzen's forground colour
DZENFG='#999999'
# Dzen's X position
DZENX=780
# Dzen's Y posit
DZENY=1
# Dzen's width
DZENWIDTH=2000
# Dzen's alignment (l=left c=center r=right)
DZENALIGN=l
# Gauge background colour
GAUGEBG='#323232'
# Gauge foreground colour
GAUGEFG='#8ba574'
# Path to your Dzen icons
ICONPATH=/home/quarks/dzen/dzen_bitmaps
# Network interface
INTERFACE=eth0
# Sound device for volume control
SNDDEVICE=Master
# Date formating
DATE_FORMAT='%A, %d.%m.%Y %H:%M:%S'
# What tiem zones to use
TIME_ZONES=(Australia/Sydney America/Los_Angeles America/New_York)
# Path to weather script
WEATHER_FORECASTER=/home/quarks/dzen/dzenWeather.pl
# Main loop interval in seconds
SLEEP=1

# Function calling intervals in seconds
DATEIVAL=20
GTIMEIVAL=60
CPUTEMPIVAL=60
MUSICIVAL=2
VOLUMEIVAL=1
# Update weather every 30 minutes
WEATHERIVAL=1800
##################################################################


# Time and date 
##################################################################
DATE_FORMAT='%A, %d.%m.%Y %H:%M:%S'

fdate() {
    date +${DATE_FORMAT}
}
##################################################################


# Global time
##################################################################
fgtime() {
    local i

    for i in $TIME_ZONES
        { print -n "${i:t}:" $(TZ=$i date +'%H:%M')' ' }
}
##################################################################

# CPU use
##################################################################
fcpu() {
   gcpubar -c 5 -i 0.1 -fg $GAUGEFG -bg $GAUGEBG -h 7 -w 70 | tail -1
}
##################################################################


# CPU temp   
##################################################################
fcputemp() {
   print -n ${(@)$(</proc/acpi/thermal_zone/THRM/temperature)[2,3]}
}
##################################################################


# HD partitions used and free space
##################################################################
fhd() {
   # Todo
}
##################################################################

# Network
##################################################################

# 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`


# MOCP song info and control
##################################################################
fmusic() {
   artist=`mocp -i | grep 'Artist' | cut -c 8-`
   songtitle=`mocp -i | grep 'SongTitle' | cut -c 11-`
   totaltime=`mocp -i | grep 'TotalTime' | cut -c 12-`
   currenttime=`mocp -i | grep 'CurrentTime' | cut -c 14-`
   state=`mocp -i | grep 'State' | cut -c 8-`
   print -n "$(echo $artist -$songtitle [)$(echo $currenttime/$totaltime] [)$(echo $state])"
}

# For Creative Audigy 2 ZS
fvolume() {
    percentage=`amixer sget Master | sed -ne 's/^.*Mono: .*\[\([0-9]*\)%\].*$/\1/p'`
    # print -n "$(echo $percentage | gdbar -fg $GAUGEFG -bg $GAUGEBG -h 7 -w 60)"

if [[ $percentage == 100 ]]
then
    print -n "$(echo $percentage | gdbar -fg '#319845' -bg $GAUGEBG -h 7 -w 60)" # Volume full
elif [[ $percentage -gt 50 ]]
then
    print -n "$(echo $percentage | gdbar -fg '#7CA655' -bg $GAUGEBG -h 7 -w 60)" # Volume half to full
elif [[ $percentage -gt 25 ]]
then
    print -n "$(echo $percentage | gdbar -fg $GAUGEFG -bg $GAUGEBG -h 7 -w 60)" # Volume quarter to half 
elif [[ $percentage -lt 26 ]]
then
    print -n "$(echo $percentage | gdbar -fg '#888E82' -bg $GAUGEBG -h 7 -w 60)" # Volume low to quarter
fi

}


# Command to toggle pause/unpause
TOGGLE="mocp -G"
# Command to increase the volume
CI="amixer -c0 sset Master 2dB+ >/dev/null"
# Command to decrease the volume
CD="amixer -c0 sset Master 2dB- >/dev/null"
##################################################################


# Weather script
##################################################################
fweather() {
   $WEATHER_FORECASTER
   }
##################################################################  



# Main function
##################################################################

DATECOUNTER=0;GTIMECOUNTER=0;CPUTEMPCOUNTER=0;MUSICCOUNTER=0;WEATHERCOUNTER=0;VOLUMECOUNTER=0

# Execute everything once
PDATE=$(fdate)
PGTIME=$(fgtime)
PCPU=$(fcpu)
PCPUTEMP=$(fcputemp)
PHD=$(fhd)
PVOLUME=$(fvolume)
PMUSIC=$(fmusic)
PWEATHER=$(fweather)

# Main loop
while :; do

PCPU=$(fcpu)
PHD=$(fhd)

   if [ $DATECOUNTER -ge $DATEIVAL ]; then
     PDATE=$(fdate)
     DATECOUNTER=0
   fi

   if [ $GTIMECOUNTER -ge $GTIMEIVAL ]; then
     PGTIME=$(fgtime)
     GTIMECOUNTER=0
   fi

   if [ $CPUTEMPCOUNTER -ge $CPUTEMPIVAL ]; then
     PCPUTEMP=$(fcputemp)
     CPUTEMPCOUNTER=0
   fi

   if [ $MUSICCOUNTER -ge $MUSICIVAL ]; then
     PMUSIC=$(fmusic)
     MUSICCOUNTER=0
   fi

   if [ $VOLUMECOUNTER -ge $VOLUMEIVAL ]; then
     PVOLUME=$(fvolume)
     VOLUMECOUNTER=0
   fi

   if [ $WEATHERCOUNTER -ge $WEATHERIVAL ]; then
     PWEATHER=$(fweather)
     WEATHERCOUNTER=0
   fi

    # 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 
    echo "| ^fg(#80AA83)^p(0)^i(${ICONPATH}/load.xbm) ^fg()${PCPU} | ^fg(#80AA83)^i(${ICONPATH}/temp.xbm)^fg()${PCPUTEMP}° | ${INTERFACE}:^fg(white)${RXR}kB/s^fg(#80AA83)^p(0)^i(${ICONPATH}/arr_down.xbm)^fg(white)${TXR}kB/s^fg(orange3)^p(0)^i(${ICONPATH}/arr_up.xbm)^fg() | ^fg()${PGTIME}| ^fg(#FFFFFF)${PDATE}   ^fg()Eindhoven: ^fg()${PWEATHER} | ^fg(#80AA83)^p(0)^i(${ICONPATH}/volume.xbm)^fg()${PVOLUME} | ^fg(#80AA83)^p(0)^i(${ICONPATH}/music.xbm)^fg()${PMUSIC}"

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

   DATECOUNTER=$((DATECOUNTER+1))
   GTIMECOUNTER=$((GTIMECOUNTER+1))
   CPUTEMPCOUNTER=$((CPUTEMPCOUNTER+1))
   WEATHERCOUNTER=$((WEATHERCOUNTER+1))
   MUSICCOUNTER=$((MUSICCOUNTER+1))
   VOLUMECOUNTER=$((VOLUMECOUNTER+1))

sleep $SLEEP

# Pass it to dzen
done | dzen2 -bg $DZENBG -fg $DZENFG -x $DZENX -y $DZENY -ta $DZENALIGN -h 16 -p -e "button2=exec:$TOGGLE;button4=exec:$CI;button5=exec:$CD" -fn $DZENFNT

Screenshot:
desktop_current-thumb.png

Last edited by quarks (2007-12-21 15:02:20)

Offline

#67 2007-12-21 15:20:06

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

My current setup with gcpubarG:

desk-cpb_th.png

Offline

#68 2007-12-21 15:46:03

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

gotmor wrote:

My current setup with gcpubarG:

http://dzen.geekmode.org/img/desk-cpb_th.png

Thanks for another source of inspiration. big_smile

Offline

#69 2007-12-27 11:55:52

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

new gdbar styles:

Further details:

dzen_dbar_styles.png

Offline

#70 2007-12-27 18:02:01

aeolist
Member
Registered: 2007-06-03
Posts: 10

Re: dzen & xmobar Hacking Thread

buttons, how did you get the updates/news notification?

does gcpubar support more than one core?

and what about mpc intergration?
-> did it with mpc | sed 1q | grep - (presumes that songs have a -)

oh and what about weather xpms?? buttons??

Last edited by aeolist (2007-12-28 16:23:38)

Offline

#71 2007-12-28 15:11:32

redbeard0531
Member
Registered: 2007-12-28
Posts: 12

Re: dzen & xmobar Hacking Thread

I took the "many dzens" approach which allowed me to have a more active bar. redbeard_dzen.png

* Clicking on the workspace list takes you to that workspace
* Hovering over the title bar shows a full width slave for large window titles (note the ... here)
* Hovering over the |{KERNEL,MAIN,DAEMON}| displays a scrollable view of those log files
* Scrolling changes the volume and clicking toggles mute. (updated in realtime using inotify)
* Hovering over the weather displays the forecast
* Hovering over the system stats shows more (to be expanded later)
* Hovering over the clock shows `cal -3` (note that the "important" part of the time is highlighted to make is easy to see)

The only real problem I have (other than running out of pixels) is that the script doesn't quit cleanly. To reload it I have to run "killall dzonky dzen2 inotail watchfile inotifywatch ;sleep 1; dzonky". If anybody has some suggestions to work around this, I'm all ears. Also, i get segfaults if I use scrolling and ^cs(), but i use $EVENTSCLEARABLE to get around that for now.

dependencies:
svn copy of dven2 and gadgets
xte (a virtual keyboard in xautomation package)
inotifytools
inotail
perl weather.com thingy
icons

dzonky:

#!/bin/sh

FG='#aaaaaa'
BG='black'
FONT='-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*'
BIGFONT='-*-terminus-*-r-normal-*-*-140-*-*-*-*-iso8859-*'
ICONPATH=/home/mstearn/bin/dzen_bitmaps

EVENTS="entertitle=scrollend,uncollapse;leavetitle=collapse;button4=scrollup;button5=scrolldown"
EVENTSCLEARABLE="entertitle=uncollapse;leavetitle=collapse"

logger (){
while true
do
    read line
    echo "$line"
done \
  | awk 'BEGIN {print "^fg(white)|^fg()'$1'^fg(white)|^fg()";fflush()}; {print ;fflush()}' \
  | sed -re 's/(([^ ]* +){3})/^fg(white)\1^fg()/'

}

key_symulator(){
while true
do
   read key
   if echo $key | grep '^[1-9]$'
   then
       xte 'keydown Alt_L' "key $key" 'keyup Alt_L'
   fi
done
}

alias my_dzen='dzen2 -xs 1 -h 18 -x $BASE -tw $WIDTH -fg $FG -bg $BG'

set_pos (){ # set_pos width_in_pixels
    BASE=$(echo $BASE + $WIDTH | bc)
    WIDTH=$1
}

BASE=0
WIDTH=0

set_pos 155
watchfile ~/.xmonad-status \
  | awk -F '|' '{print $1;fflush()}' \
  | my_dzen  -e 'button1=menuprint' -ta c -w 160 -m h -l 9 \
  | key_symulator &

set_pos 340
watchfile ~/.xmonad-status \
  | awk -F '|' '/\|/ {print $3 "\n" $3;fflush()}' \
  | my_dzen -fn $FONT -e $EVENTSCLEARABLE -ta l -l 1 -u &

set_pos 75
gcpubar -h 18 -w 50 -gs 0 -gw 1 -i 2  -s g -l "^i(${ICONPATH}/cpu-scaled.xpm)" \
  | my_dzen -fn $FONT -e '' -ta l&

set_pos 60
inotail -f -n 50 /var/log/kernel.log \
  | logger KERNEL \
  | my_dzen -fn $FONT -e $EVENTS -ta c -l 20 &

set_pos 50
inotail -f -n 50 /var/log/messages.log \
  | logger MAIN \
  | my_dzen -fn $FONT -e $EVENTS -ta c -l 20 &

set_pos 60
inotail -f -n 50 /var/log/daemon.log \
  | logger DAEMON \
  | my_dzen -fn $FONT -e $EVENTS -ta c -l 20 &


set_pos 100
while [ $? -ne 1  -a  $? -ge 0  ]  && echo -n '^fg()'
do
    if (amixer sget Master | grep -qF '[off]')
    then
        color='#3C55A6'
        icon=${ICONPATH}/vol-mute.xbm
    else
        color='#7CA655'
        icon=${ICONPATH}/vol-hi.xbm
    fi

    percentage=$(amixer sget Master | sed -ne 's/^.*Front Left: .*\[\([0-9]*\)%\].*$/\1/p')

    echo $percentage | gdbar -fg $color -bg darkred -h 18 -w 50 -l "^fg(lightblue)^i($icon)^p(2)^fg()"
    inotifywait -t 30 /dev/snd/controlC0 -qq
done \
  | my_dzen -fn $FONT -ta l -e \
       'button1=exec:amixer sset Master toggle -q;button4=exec:amixer sset Master 1+ -q;button5=exec:amixer sset Master 1- -q;' &


set_pos 45
while echo -n ' ' 
do
    ~/bin/dzenWeather/dzen_weather.pl
    sleep 300 # 5 min
done \
  | my_dzen -fn $FONT -ta l -w 145 -l 2 -u -e $EVENTSCLEARABLE &

 
set_pos 373
CONKY1='^cs()
^tw()^i('$ICONPATH'/temp.xbm)$acpitemp^p(3)^i('$ICONPATH'/${exec if (acpitool -a |grep -qF on-line) ; then echo -n power-ac.xbm; else echo -n power-bat.xbm; fi})$battery^fg(white)^i('$ICONPATH'/net-wifi.xbm)(${wireless_essid wlan0} ${wireless_link_qual_perc wlan0} ^fg(#BA9093)${addr wlan0}^fg(#80AA83)^p(3)^i('${ICONPATH}'/arr_up.xbm)${upspeedf wlan0}^p(3)^i('${ICONPATH}'/arr_down.xbm)${downspeedf wlan0}^fg(white))  
LOADS: ^fg(#ff0000)${loadavg 1 2 3}
UPTIME: $uptime
'
conky -t "$CONKY1" \
  | my_dzen -fn $FONT -e $EVENTSCLEARABLE -ta r -l 10 -w 300&


set_pos 182
CONKY2='^tw()${time %a %b %d ^fg(white)%I:%M^fg():%S%P}^p(5)
${execi 3600  (cal -3 | awk "BEGIN {print \\"^cs()\\"}; {print \\"^p(15)\\", \\$0}")} '
conky -t "$CONKY2" \
  | my_dzen -fn $BIGFONT -e $EVENTSCLEARABLE -ta r -w 550 -l 8 &

# vim:set nospell ts=4 sts=4 sw=4:

watchfile: (cats a file every time it changes. use '-t s' to force it to refresh at least every s seconds)

#!/bin/bash

cat "$@" ; echo
while [ $? -ne 1 -a $? -ge 0 ] && echo -n '^fg()'
do
    cat "$@" ; echo
    inotifywait -e modify -qq $@ 
done

Dynamic log section in xmonad.hs:

redbeardPP = defaultPP { ppHiddenNoWindows = dzenColor "#33FF00"  ""
                      , ppHidden  = dzenColor "white"  ""
                      , ppCurrent = dzenColor "yellow" ""
                      , ppVisible = dzenColor "#FF2222" ""
                    --, ppUrgent  = dzenColor "red"    "yellow"
                      , ppSep     = " | "
                      , ppWsSep   = "\n"
                      , ppTitle   = id
                      , ppLayout  = \s -> " "
                      , ppOutput  = writeFile "/home/mstearn/.xmonad-status" 
                                        . ("^cs()\n"++)
                      } 

myLogHook = do ewmhDesktopsLogHook
               dynamicLogWithPP redbeardPP
               return ()
 

myUrgencyHook = withUrgencyHook dzenUrgencyHook 
        { args = ["-bg", "yellow", "-fg", "black" ,"-p", "3", "-xs", "1"] }

Last edited by redbeard0531 (2007-12-28 15:16:20)

Offline

#72 2007-12-29 11:17:10

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

aeolist wrote:

buttons, how did you get the updates/news notification?

I used the conky one that floats around these forums.  Here it is:

~/bin/dzen_updates.pl

#! /usr/bin/perl -w
use strict;
# November 15, 2006
# Daniel Vredenburg (Vredfreak)
# This is a program that checks for package updates for Arch Linux users.

open (MYINPUTFILE, "/var/log/updates.log") or die "No such file or directory: $!";

my $i = 0;
while(<MYINPUTFILE>)
{
        if (/^(.*)\/(.*)(\..*\..*\.)/)  {
                #print " \n";
                $i++;
        }

}
if ($i == 0) {
        print "up to date";
} else {
        print "available ($i)";
}
close(MYINPUTFILE);

Sometimes I change the print commands to alter the colour when there are updates available.

Then you need this in your /etc/cron.d/hourly directory:

pacsync.sh

#!/bin/bash

# This issues a command to 1. Sync the package database, 
# 2. Check for upgradable packages, 3. print the URL of any possible upgrade. 
# The output of our command gets written to updates.log, which we will use 
# dzen_updates.pl to parse to see if there are any available updates.

pacman -Syup --noprogressbar > /var/log/updates.log

Which will of course do a package sync each hour and put the results in /var/log/updates.log.  Make sure this is writeable by root and readable by you.

aeolist wrote:

oh and what about weather xpms?? buttons??

As I mentioned earlier in the thread, once you've signed up for weather.com's xml service they send you a link to a zip file containing everything you need, including xpms.  Then you'll need to open the 32x32 folder, and run the following command (courtesy of gotmor):

for i in *.png; do convert -scale 14x14 "$i" "${i%%.*}-scaled.xpm"; done

And then use these images when following the weather instructions from Rob's site.

Keep in mind you will also need to patch dzen2 to allow full-colour xpms.  For completeness, and because this post isn't nearly long enough yet, here's the PKGBUILD:

pkgname=dzen2
pkgver=0.8.5
pkgrel=1
arch=(i686 x86_64)
pkgdesc="X notification utility"
url="http://gotmor.googlepages.com/dzen"
license=("MIT")
depends=('libx11')
makedepends=('gcc')
source=(http://gotmor.googlepages.com/$pkgname-$pkgver.tar.gz)
md5sums=('5978620c2124c8a8ad52d7f17ce94fd7')

build()
{
  cd $startdir/src/$pkgname-$pkgver

  patch config.mk <<EOF
7,8c7,8
< PREFIX = /usr/local
< MANPREFIX = \${PREFIX}/share/man
---
> PREFIX = /usr
> MANPREFIX = \${PREFIX}/man
10,11c10,11
< X11INC = /usr/X11R6/include
< X11LIB = /usr/X11R6/lib
---
> X11INC = /usr/include
> X11LIB = /usr/lib
22,23c22,23
< LIBS = -L/usr/lib -lc -L\${X11LIB} -lX11
< CFLAGS = -Os \${INCS} -DVERSION=\"\${VERSION}\"
---
> #LIBS = -L/usr/lib -lc -L\${X11LIB} -lX11
> #CFLAGS = -Os \${INCS} -DVERSION=\"\${VERSION}\"
26,27c26,27
< #LIBS = -L/usr/lib -lc -L\${X11LIB} -lX11 -lXpm
< #CFLAGS = -Os \${INCS} -DVERSION=\"\${VERSION}\" -DDZEN_XPM
---
> LIBS = -L/usr/lib -lc -L\${X11LIB} -lX11 -lXpm
> CFLAGS = -Os \${INCS} -DVERSION=\"\${VERSION}\" -DDZEN_XPM
EOF

  make || return 1
  mkdir -p $startdir/pkg/usr/share/licenses/$pkgname
  cp $startdir/src/$pkgname-$pkgver/LICENSE $startdir/pkg/usr/share/licenses/$pkgname/license
  chmod 644 $startdir/pkg/usr/share/licenses/$pkgname/license
  make DESTDIR=$startdir/pkg install
}

Cthulhu For President!

Offline

#73 2007-12-31 11:11:33

Don-DiZzLe
Member
From: Nederland
Registered: 2007-03-31
Posts: 233

Re: dzen & xmobar Hacking Thread

Ok I did the code to convert the 32x32 xpms but I get a message saying the convert command cannot be found, which proggie do i need to install in order for it to work?

Offline

#74 2007-12-31 11:36:52

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

Don-DiZzLe wrote:

Ok I did the code to convert the 32x32 xpms but I get a message saying the convert command cannot be found, which proggie do i need to install in order for it to work?

You need ImageMagick.

I'm having some trouble getting the new gcpubarG to work.
I wan't it to be a small rectangular graph like in gotmor's screenshot.  however
"gcpubarg -s g -w 200 -h 16 -gs 1 -gw 3" displays the usage options in the dzen statusbar and with just "gcpubarg" dzen doesn't even show up.

Executing "gcpubarg" on the command line gives the correct values I guess ("^fg(white)^p(1)^r(1x0+0-1" and so on).

Last edited by quarks (2007-12-31 14:38:42)

Offline

#75 2007-12-31 18:24:25

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

quarks wrote:

I'm having some trouble getting the new gcpubarG to work.
I wan't it to be a small rectangular graph like in gotmor's screenshot.  however
"gcpubarg -s g -w 200 -h 16 -gs 1 -gw 3" displays the usage options in the dzen statusbar and with just "gcpubarg" dzen doesn't even show up.

Executing "gcpubarg" on the command line gives the correct values I guess ("^fg(white)^p(1)^r(1x0+0-1" and so on).

gcpubarG is obsolete, you just need to grab the latest development version of dzen:

svn checkout http://dzen.googlecode.com/svn/trunk/ dzen

and use the gcpubar that comes with it.

Have a look at the Wiki entry for further details.

Offline

Board footer

Powered by FluxBB