dzen script archive

collection of ideas for dzen based scripts 

Visit dzen's wiki for further scripts, tips, icon packs, etc.

Popup dictionary

Requirements:

Screenshot:

Usage:

  • save the script below to a file called dzendict.sh
  • define a keybinding in your favourite windowmanager or with xmodmap to launch dzendict.sh
  • select some text with the mouse
  • hit the defined keybinding
  • mouse button1 exits the dictionary

Script:

#!/bin/sh
# simple popup dictionary, (c) 2007 by Robert Manea

LOOKUP=`sselp`

(echo "$LOOKUP"; dict "$LOOKUP") | \
dzen2 -l 8 -p -w 500 -bg darkblue -fg grey75 -x 300 -y 300 \
-fn '-*-profont-*-*-*-*-11-*-*-*-*-*-iso8859' \
-e 'onstart=scrollhome,uncollapse;button4=scrollup;button5=scrolldown;button1=exit'

 

Powerful reminder

Requirements:

 

Screenshot:

Usage:

  • execute the script below
  • alternatively you can put it into .xinitrc

Script:

remind -z -k"(echo %s; sleep 30) | dzen2"

 

 CPU Utilization

Requirements:

Screenshot:

 

 

Script:

 cpubar | dzen2 -ta l -w 275

 

 Memory meter

Requirements:

Description:

  • Save the script below to a file and run it
  • This script introduces dbar a general purpose percentage/progress meter
  • See dbar.c for documentation

 

Script:

while :; do
awk '/MemTotal/ {t=$2}; /MemFree/ {f=$2}; END {print t-f " " t}' /proc/meminfo | dbar -s ':' -l 'Mem:'
sleep 5
done | dzen2


 Menus with descriptions

Motivation:

  • You want to replace your full blown menu with a simple dzen style solution 
  • You want  to comment the program names to better remember what each one does
  • You do not want to write a separate parser just to get rid of those comments

 

Solution:

Let the shell do the parsing job!

A sample menu file could look like this, we'll name it devmenu.dzen:

    vim        # keep it real

    insight    # graphical debugger

    meld      # diff tool

    nethack  # i'm feeling  chilly

You get the trick.. 

 

Now let dzen display the menu for us:

echo "Dev Menu" | dzen2 -w 250 -p -m -l 4 < devmenu.dzen 

 

Mouse button1 (left button) will lauch the selected program.

 

Download progress indicator

Requirements:

 

Usage:

  • save the script below to a file called  dget.sh
  • start downloads with: dget.sh url1 url2 ... urlN
  • cancel download by clicking with the right mousebutton into dzen
  • when all downloads have finished there will be a message displayed
  • then dzen quits itself after 5 seconds


Script:

#!/bin/sh
#
# (c) 2007 by Robert Manea
#
# display download progress and cancel download
# on button3 click
#

(wget --progress=dot "$@" 2>&1; echo "Download(s) finished.."; sleep 5) | \
 dzen2 -ta l -w 500 -fn '-*-fixed-*-*-*-*-9-*-*-*-*-*-*-*' \                                                                                                                         
       -e 'button3=exec:pkill -15 wget,exit'

  

 

XEcho - courtesy of Daniel Wagner

Requirements:

  • standard UNIX tools 

 

Usage:

  • temporarily show a command's output in a dzen window
  • save the script below to a file called xecho.sh
  • invoke it like: xecho.sh  cal 2007

 

Screenshot:

 

Script:

 #!/bin/sh
RESOLUTIONX=1600
RESOLUTIONY=1200
FONTWIDTH=6
FONTHEIGHT=13
BORDERX=13
BORDERY=6

OPTIONS="-p 10 -ta l -sa l -fn fixed -e onstart=uncollapse;button1=exit;button2=exit;button3=exit"
OUTPUT=`mktemp`
$* >$OUTPUT

H=`wc -l <$OUTPUT`
W=`wc -L <$OUTPUT`
N=`echo $H - 1 | bc`
WIDTH=`echo  $BORDERX '+' $FONTWIDTH  '*' $W | bc`
HEIGHT=`echo $BORDERY '+' $FONTHEIGHT '*' $H | bc`
X=`echo '(' $RESOLUTIONX - $WIDTH ')'  / 2 | bc`
Y=`echo '(' $RESOLUTIONY - $HEIGHT ')' / 2 | bc`

dzen2 -l $N -x $X -y $Y -w $WIDTH $OPTIONS <$OUTPUT
rm $OUTPUT