You are not logged in.
Dzen2 is an amazing piece of software and its flexibility continuously amazes me. After looking at background changer script found here: http://bbs.archlinux.org/viewtopic.php?id=40637&p=6 I realized it would be really easy to convert it to an app launcher.
First of all I created a directory to house the scripts I use in the app launcher and one empty file called 00. The empty file is a crude workaround so I can see all the items in the menu. Such file is firefox3, which contains nothing but this:
firefox3&
Remember to chmod +x on the items.
Then I modified the changer script, so it would open with a right click, have a menu icon and simple decorations:
# dzen menu script
# direcory with execs
TAG='(2x17)'
TAG1='(5x2)'
ICON='(/home/edgar/dzen_bitmaps/xbm8x8/arch_10x10.xbm)'
DIR='/home/edgar/bin/dzenbin/'
COUNT=$(expr `ls $DIR | wc -l` - 1) && [ $COUNT -gt 30 ] && COUNT=30
(echo ^i$ICON;
for i in $(ls $DIR); do
echo " "^r$TAG^r$TAG1 $i
done
) \
| dzen2 -y 783 -ta c -sa l -tw 30 -w 95 -bg '#9ab8c2' -fg '#44434f' -fn '-*-dina-medium-r-*-*-15-*-*-*-*-*-iso8859-1' -p -l $COUNT -m \
-e 'button3=togglecollapse;leaveslave=collapse;button4=scrollup;button5=scrolldown;button1=menuprint' \
| while read FNAME; do "$DIR$FNAME"; done
after that I put dzen menu script in my .xinitrc. The result looks like this:
It looks good IMO and adds extra functionality to a statusbar.
Now I have to find out how to put icons in to that menu. Any ideas guys? Any other input is also highly appreciated.
Last edited by Ashren (2008-03-31 13:26:41)
Offline
I am happy someone made use, of what I tried to do :)
Offline
Your idea worked tch. When tinkering with dzen2 I sometimes get the feeling that the possibilities are endless - and I guess they are. I've been thinking about adding program specific icons to the above menu and I guess it wouldn't be too hard. Remember that full color xpm's can be used as well.
Last edited by Ashren (2008-03-13 10:53:45)
Offline
Really nice, will definitely implement this in my awesome setup.
Offline
Your idea worked tch. When tinkering with dzen2 I sometimes get the feeling that the possibilities are endless - and I guess they are. I've been thinking about adding program specific icons to the above menu and I guess it wouldn't be too hard. Remember that full color xpm's can be used as well.
Application icons should be fairly easy. One particularily simple way is to name the icons just like the application itself, e.g. firefox would be associated with firefox.xpm or firefox.xbm.
In this example icons are expected to be XPMs, just change the marked line if you'd like XBMs.
#!/bin/bash
TAG=2x17
TAG1=5x2
ICON=/path/to/mainicon.xpm
DIR=/path/to/apps_and_icons
COUNT=$(expr `ls $DIR | wc -l` - 1) && [ $COUNT -gt 30 ] && COUNT=30
(echo "^i(${ICON})";
for i in $(ls $DIR|sed -e '/.xbm$/d;/.xpm$/d'); do
echo "^r(${TAG})^r(${TAG1}) ^i(${DIR}/${i}.xpm) $i" # change 'xpm' to 'xbm' for this filetype
done
) | dzen2 -y 783 -ta c -sa l -tw 30 -w 95 -bg '#9ab8c2' -fg '#44434f' -p -l $COUNT -m
Note, that you don't need the "read" construct for a simple launcher as dzen will execute the clicked entry by default.
Another method to handle icons would be a file containing mappings of application to icon names, parse that file with a small script and output to dzen.
Last edited by gotmor (2008-03-13 12:52:40)
Offline
Thanks for the tip gotmor. Finally I got around to creating a decent script and here's the result.
#!/bin/bash
#
# Dzen2 App Launcher
# -tw = Width of titlebar, -w = Width of slavewindow,
# -l = length of slavewindow. Remember to adjust -l accordingly when adding
# apps.
#
# Needed Applications:
AP1=firefox3
AP2=gimp
AP3=leafpad
AP4=terminal
AP5=
# Deco:
DC1=3x17
DC2=8x8
DC3=8x3
DC4=3x3
#FONT
FONT="-*-dina-medium-r-*-*-15-*-*-*-*-*-iso8859-1"
# Colors:
FG1=#9ab8c2
FG2=#f57900
FG3=#D9A509
# Icons:
ICM=~/dzen_bitmaps/xbm8x8/arch_10x10.xbm
IC1=~/dzen_bitmaps/xbm8x8/fox.xbm
IC2=~/dzen_bitmaps/xbm8x8/shroom.xbm
IC3=~/dzen_bitmaps/xbm8x8/info_03.xbm
IC4=~/dzen_bitmaps/xbm8x8/dish.xbm
# Text parsed to Dzen2
(echo "^fg(${FG2})^i(${ICM})"; echo -e "^fg(${FG1})\
^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC1})^fg(${FG1}) ${AP1} ^pa(106)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC2})^fg(${FG1}) ${AP2} ^pa(106)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC3})^fg(${FG1}) ${AP3} ^pa(106)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC4})^fg(${FG1}) ${AP4} ^pa(106)^r(${DC3})^r(${DC2})^r(${DC1})")\
| (dzen2 -y '783' -fn "$FONT" -bg '#43464f' -fg '#9ab8c2' -l 4 -tw 30 -w 125 -m -p -e 'button3=togglecollapse;leaveslave=collapse;button1=menuexec')
This solution is much more clean than having a directory with scripts and icons. The dzen2 readme was a great help and I think I have created a decent template to create menus from.
Last edited by Ashren (2008-04-10 08:38:42)
Offline
This is great, exactly the kind of simplistic menu I've been looking for...
The only thing that bugs me is having to right-click to bring up the menu, I realize that setting it to left-click conflicts with the left-clicking of the menu items to launch them...
is there any way to get the menu to open via left-click ? if so then my life would be complete
Offline
Thanks Evanlec.
To start menu with left click change "button3=togglecollapse" to "button1=togglecollapse" in the dzen2 command line. If you leave out this parameter, the menu will uncollapse with mouse over.
Updated script to include font value.
Last edited by Ashren (2008-04-10 08:41:54)
Offline
right, well i tried that, and it doesnt work
'button1=togglecollapse;button1=menuexec'
start the menu and left clicking on it does nothing...
*Edit*
Fixed it by using 'button1=togglecollapse,menuexec'
Last edited by Evanlec (2008-04-10 11:19:10)
Offline
on anther note, perhaps related, it seems that when i click on the dzen to open the menu, the first app that i have listed .. in this case firefox .. gets launched...
is this a bug ? way to correct this?
I'm guessing this has to do with me setting button1 to both open the menu and to launch the apps....via button1=togglecollapse,menuexec
perhaps theres a way around this?
Last edited by Evanlec (2008-04-13 11:17:37)
Offline
Hi Evanlec,
Yep, you're right the behavior is caused by your settings. Have you tried experimenting with button1=enterslave instead of togglecollapse?
I can think of a possible dirty hack to solve your problem, but see if you can fix it yourself first with help from this wiki: http://dzen.geekmode.org/dwiki/doku.php
This might help you as well:
==================================
dzen, (c) 2007 by Robert Manea
==================================
A general purpose messaging, notification and menu program
The "gadgets" subdirectory contains some tools that you can
use in combination with dzen.
Script archive with a collection of interesting ideas:
http://gotmor.googlepages.com/dzenscriptarchive
Use "./help" to view a nicely formated version of the documentation.
Features
--------
* scriptable in any language
* dynamic colorizer
* keyboard support
* single line and/or windows holding multiple lines
* menu functionality
* in-text formating language
* flexible event/action mechanism
* hideable, collapsable
* Xinerama support
Requirements
------------
In order to build dzen you need the Xlib header files.
Installation
------------
Edit config.mk to match your local setup (dzen is installed into
the /usr/local namespace by default).
Afterwards enter the following command to build and install dzen (if
necessary as root):
make clean install
Optionally if you want to use dzen's gadgets:
cd gadgets
make clean install
Note: By default dzen will not be compiled with Xinerama and XPM support.
Uncomment the respective lines in config.mk to change this.
Contact:
--------
Feature requests, patches or anything else related to dzen can be send
to: rob dot manea at gmail dot com
Running dzen
------------
dzen accepts a couple of options:
-fg foreground color
-bg background color
-fn font
-ta alignement of title window content
l(eft), c(center), r(ight)
-tw title window width
-sa alignment of slave window, see "-ta"
-l lines, see (1)
-e events and actions, see (2)
-m menu mode, see (3)
-u update contents of title and
slave window simultaneously, see (4)
-p persist EOF (optional timeout in seconds)
-x x position
-y y position
-h line height (default: fontheight + 2 pixels)
-w width
-xs number of Xinerama screen
-v version information
see (5) for the in-text formating language.
Window layout
-------------
Dzen's window layout is as follows:
------------------------------------------
| Title window, single line |
`------------------------------------------´
| |
| scrollable |
| Slave window |
| multiple lines |
| lines to display simultaneously |
| controlled with the |
| '-l' option |
| |
| |
`------------------------------------------´
The first line you provide to dzen always goes to the title window,
all other consecutive lines will be drawn to the slave window unless
you explicitly overide this with the (5) In-text formating language
command ^tw().
QA:
---
Q1: I don't want a slave window, what to do?
A1: Do not provide the '-l' option, all lines will be displayed
in the title window, this is the default behaviour.
Q2: I used the '-l' option but no slave window appears.
A2: With the default event/action handling the slave window will
only be displayed if you hoover with the mouse over the title
window. See "(2) Events and actions" if you'd like to change
this.
Q3: If I echo some text or cat a file dzen closes itself imediatelly.
A3: There are 2 different approaches dzen uses to terminate itself,
see next section "Termination".
Q4: Ok, the title and slave thing works, can I update the
contents of both windows at the same time?
A4: Sure, see "(4) Simultaneous updates" or use the in-text
command "^tw()" to explicitly draw to the title windwow.
See section (5) for further details
Q5: Can i chnage color of my input at runtime?
A5: Yes, you can change both background and foreground colors and
much more See "(5) In-Text formating language"
Q6: Can I use dzen as a menu?
A6: Yes, both vertical and horizontal menus are supported.
See "(3) Menu" for further details.
Termination:
------------
dzen uses two different approaches to terminate itself:
* Timed termination: if EOF is received -> terminate
- unless the '-p' option is set
· '-p' without argument persist forever
· '-p' with argument n persist for n seconds
* Interactive termination: if mouse button3 is clicked -> terminate
- this is the default behaviour, see (2)
- in some modes the Escape key terminates too, see (2)
Return values:
--------------
0 - dzen received EOF
1 - some error occured, inspect the error message
user defined - set with 'exit:retval' action, see (2)
(1) Option "-l": Slave window
--------------------------------
Enables support for displaying multiple lines. The parameter to "-l"
specifies the number of lines to be displayed.
These lines of input are held in the slave window which becomes active as soon
as the pointer enters the title (default action) window.
If the mouse leaves the slave window it will be hidden unless it is set
sticky by clicking with Button2 into it (default action).
Button4 and Button5 (mouse wheel) will scroll the slave window up
and down if the content exceeds the window height (default action).
(2) Option '-e': Events and actions
-----------------------------------
dzen allows the user to associate actions to events.
The command line syntax is as follows:
-e 'event1=action1:option1:...option<n>,...,action<m>;...;event<l>'
Every event can take any number of actions and every action can take any number
of options. (By default limited to 64 each, easily changable in action.h)
An example:
-e 'button1=exec:xterm:firefox;entertitle=uncollapse,unhide;button3=exit'
Meaning:
button1=exec:xterm:firefox;
on Button1 event (Button1 press on the mouse) execute xterm and
firefox.
Note: xterm and firefox are options to the exec action
entertitle=uncollapse,unhide;
on entertitle (mouse pointer enters the title window) uncollapse
slave window and unhide the title window
button3=exit
on button3 event exit dzen
Supported events:
-----------------
onstart Perform actions right after startup
onexit Perform actions just before exiting
onnewinput Perform actions if there is new input for the slave window
button1 Mouse button1 released
button2 Mouse button2 released
button3 Mouse button3 released
button4 Mouse button4 released (usually scrollwheel)
button5 Mouse button5 released (usually scrollwheel)
button6 Mouse button6 released
button7 Mouse button7 released
entertitle Mouse enters the title window
leavetitle Mouse leaves the title window
enterslave Mouse enters the slave window
leaveslave Mouse leaves the slave window
sigusr1 SIGUSR1 received
sigusr2 SIGUSR2 received
key_KEYNAME Keyboard events (*)
(*) Keyboard events:
--------------------
Every key can be bound to an action (see below). The format is:
key_KEYNAME where KEYNAME is the name of the key as defined in
keysymdef.h (usually: /usr/include/X11/keysymdef.h). The part
after 'XK_' in keysymdef.h must be used for KEYNAME.
Supported actions:
------------------
exec:command1:..:n execute all given options
menuexec executes selected menu entry
exit:retval exit dzen and return 'retval'
print:str1:...:n write all given options to STDOUT
menuprint write selected menu entry to STDOUT
collapse collapse (roll-up) slave window
uncollapse uncollapse (roll-down) slave window
togglecollapse toggle collapsed state
stick stick slave window
unstick unstick slave window
togglestick toggle sticky state
hide hide title window
unhide unhide title window
togglehide toggle hide state
raise raise window to view (above all others)
lower lower window (behind all others)
scrollhome show head of input
scrollend show tail of input
scrollup:n scroll slave window n lines up (default n=1)
scrolldown:n scroll slave window n lines down (default n=1)
grabkeys enable keyboard support
ungrabkeys disable keyboard support
grabmouse enable mouse support
only needed with specific windowmanagers, such as fluxbox
ungrabmouse release mouse
only needed with specific windowmanagers, such as fluxbox
Note: If no events/actions are specified dzen defaults to:
Title only mode:
----------------
-e 'button3=exit:13'
Multiple lines and vertical menu mode:
--------------------------------------
-e 'entertitle=uncollapse,grabkeys;
enterslave=grabkeys;leaveslave=collapse,ungrabkeys;
button1=menuexec;button2=togglestick;button3=exit:13;
button4=scrollup;button5=scrolldown;
key_Escape=ungrabkeys,exit'
Horizontal menu mode:
---------------------
-e 'enterslave=grabkeys;leaveslave=ungrabkeys;
button4=scrollup;button5=scrolldown;
key_Left=scrollup;key_Right=scrolldown;
button1=menuexec;button3=exit:13
key_Escape=ungrabkeys,exit'
If you define any events/actions, there is no default behaviour,
i.e. you will have to specify _all_ events/actions you want to
use.
(3) Option '-m', Menu
---------------------
Dzen provides two menu modes, vertical and horizontal menus. You can
access these modes by adding 'v'(ertical) or 'h'(horizontal) to the
'-m' option. If nothing is specified dzen defaults to vertical menus.
Vertical menu, both invocations are equivalent:
dzen2 -p -l 4 -m < file
dzen2 -p -l 4 -m v < file
Horizontal menu:
dzen2 -p -l 4 -m h < file
All actions beginning with "menu" work on the selected menu entry.
Note: Menu mode only makes sense if '-l <n>' is specified!
Horizontal menus have no title window, so all actions
affecting the title window will be silently discarded
in this mode.
(4) Option '-u', Simultaneous updates
-------------------------------------
This option provides facilities to update the title and slave window at
the same time.
The way it works is best described by an example:
Motivation:
We want to display an updating clock in the title and some log
output in the slave window.
Solution:
while true; do
date # output goes to the title window
dmesg | tail -n 10 # output goes to the slave window
sleep 1
done | dzen2 -l 10 -u
For this to work correctly it is essential to provide exactly the number
of lines to the slave window as defined by the parameter to '-l'.
(5) In-text formating language:
-------------------------------
This feature allows to dynamically (at runtime) format the text dzen
displays.
Currently the following commands are supported:
Colors:
-------
^fg(color) set foreground color
^fg() without arguments, sets default fg color
^bg(color) set background color
^bg() without arguments, sets default bg color
Graphics:
---------
^i(path) draw icon specified by path
Supported formats: XBM and optionally XPM
^r(WIDTHxHEIGHT) draw a rectangle with the dimensions
WIDTH and HEIGHT
^ro(WIDTHxHEIGHT) rectangle outline
^c(RADIUS) draw a circle with size RADIUS pixels
^co(RADIUS) circle outline
Positioning:
------------
^p(PIXEL) position next input amount of PIXELs to the right
or left of the current position
a.k.a. relative positioning
^pa(PIXEL) position next input at PIXEL
a.k.a. absolute positioning
For maximum predictability ^^pa() should only be
used with '-ta l' or '-sa l'.
Other:
------
^tw() draw to title window
This command has some annoyances, as only
the input after the command will be drawn
to the title window, so it is best used
only once and as first command per line.
^cs() clear slave window
This command must be the first and only command
per line.
^ib(VALUE) ignore background setting, VALUE can be either
1 to ignore or 0 to not ignore the bg color set
with ^bg(color).
This command is useful in combination with ^p()
and ^pa() in order to position the input inside
other already drawn input.
Example:
^ib(1)^fg(red)^ro(100x15)^p(-98)^fg(blue)^r(20x10)^fg(orange)^p(3)^r(40x10)^p(4)^fg(darkgreen)^co(12)^p(2)^c(10)
These commands can appear anywhere and in any combination in dzen's
input.
The color can be specified either as symbolic name (e.g. red,
darkgreen, etc.) or as #rrggbb hex-value (e.g. #ffffaa).
Icons must be in the XBM or optionally XPM format, see the "bitmaps"
directory for some sample icons. With the standard "bitmap" application
you can easily draw your own icons.
Note: Displaying XPM (pixmap) files imposes a somewhat
higher load than lightweight XBM files, so use
them with care in tight loops.
Rectangles will be truncated to the maximum possible size if you specify
a size bigger than dzen's window.
Doubling the '^^' character removes the special meaning from it.
Some examples:
Input:
^fg(red)I'm red text ^fg(blue)I am blue
Input:
^bg(#ffaaaa)The ^fg(yellow)text to ^bg(blue)^fg(orange)colorize
Input:
^fg(grey70)Some text containing ^^ characters
Input for icons:
^i(bitmaps/envelope.xbm) I am an envelope ^fg(yellow)and ^i(bitmaps/battery.xbm) I'm a baterry.
Input for rectangles:
6x4 rectangle ^r(6x4) ^fg(red)12x8 ^r(12x8) ^fg(yellow)and finally 100x15 ^r(100x15)
Input for relative positioning:
Some text^p(100)^fg(yellow)100 pixels to the right^p(50)^fg(red)50 more pixels to the right
Examples:
---------
* Display message and timeout after 10 seconds:
(echo "This is a message"; sleep 10) | dzen2 -bg darkred -fg grey80 -fn fixed
* Display message and never timeout:
echo "This is a message"| dzen2 -p
* Display updating single line message:
for i in $(seq 1 20); do A=${A}'='; print $A; sleep 1; done | dzen2
* Display header and a message with multiple lines:
(echo Header; cal; sleep 20) | dzen2 -l 8
Displays "Header" in the title window and the output of cal in the 8
lines high slave window.
* Display updating messages:
(echo Header; while true; do echo test$((i++)); sleep 1; done) | dzen2 -l 12
The slave window will update contents if new input has arrived.
* Display log files:
(su -c "echo LOGFILENAME; tail -f /var/log/messages") | dzen2 -l 20 -x 100 -y 300 -w 500
* Monthly schedule with remind:
(echo Monthly Schedule; remind -c1 -m) | dzen2 -l 52 -w 410 -p -fn lime -bg '#e0e8ea' -fg black -x 635
* Simple menu:
echo "Applications" | dzen2 -l 4 -p -m < menufile
* Horizontal menu without any files:
{echo Menu; echo -e "xterm\nxclock\nxeyes\nxfontsel"} | dzen2 -l 4 -m h -p
* Extract PIDs from the process table:
{echo Procs; ps -a} | dzen2 -m -l 12 -p \
-e 'button1=menuprint;button3=exit;button4=scrollup:3;button5=scrolldown:3;entertitle=uncollapse;leaveslave=collapse' \
| awk '{print $1}'
* Dzen as xmonad (see http://xmonad.org) statusbar:
status.sh | dzen2 -ta r -fn '-*-profont-*-*-*-*-11-*-*-*-*-*-iso8859' -bg '#aecf96' -fg black \
-p -e 'sigusr1=raise;sigusr2=lower;onquit=exec:rm /tmp/dzen2-pid;button3=exit' & echo $! > /tmp/dzen2-pid
Have fun.
Last edited by Ashren (2008-04-13 19:28:27)
Offline
erm I feel like an idiot but how can i show my workspaces on dzen with focus on the one i am atm.
couldn't find a tutorial in this way.
Offline
erm I feel like an idiot but how can i show my workspaces on dzen with focus on the one i am atm.
couldn't find a tutorial in this way.
I'm guessing for awesome-wm ? i would like that too (awesome user myself)
btw whered you get that nifty profile icon
Offline