百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

dzen

> 编程语言
开源

Dzen 是一个用于 X11 的通用消息传递、通知和菜单程序。

610 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Dzen 是一个用于 X11 的通用消息传递、通知和菜单程序。

==================================== dzen, (c) 2007-2010 by Robert Manea

Dzen is a general purpose messaging, notification and menuing program for X11. It was designed to be fast, tiny and scriptable in any language.

Features

* Small, fast, very tiny set of dependencies (Xlib only by default)
* Scriptable in any language
* Sophisticated formating language - including colours, icons, graphics
* Versatile - display all sorts of information
* Interactive - user defined mouse and keyboard actions
* Optional XFT support
* Optional 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:

bash
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.

X resources

Dzen is able to read font and color setting from X resources. As an example you can add following lines to ~/.Xresources

dzen2.font: --fixed------------* dzen2.foreground: #22EE11 dzen2.background: black

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,...,action;...;event'

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 ' 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

** DEPRECATED **

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 & control language:

This feature allows to dynamically (at runtime) format the text dzen displays and control its behaviour.

Currently the following commands are supported:

Note: Doubling the '^' character ('^^') will remove the special meaning from it.

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:

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言