Use dzen2 from Node.js.
Last updated 4 years ago by goto-bus-stop .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dzen2 
SYNC missed versions from official npm registry.


Use dzen2 as a Node.js stream.


npm install --save dzen2


const dzen2 = require('dzen2')

const dz = dzen2({
  foreground: 'red',
  background: 'white'

dz.write('Hello world!')
setTimeout(() => {
  dz.write('Yes this is dog')
}, 3000)


stream = require('dzen2')(options)

Spawn a dzen process. stream is a stream, write strings to it to display them.


  • spawn: (Bool=true) Whether to spawn a dzen process. Set to false if you want to pipe the dzen formatted stream to a separate dzen instance. If true, all options are also passed through to spawn.
  • events: (String) List of events and actions. See Events and actions.
  • eventServer: (Bool=false) Enable events server. Note: this options has been renamed from events.

If spawn is true, the stream has a process property with the spawned process.

pr = require('dzen2/spawn')(options)

Spawn a dzen process. Returns a plain ChildProcess. You can pipe a stream to its stdin.


  • path - Path to the dzen2 binary to use. Defaults to dzen2-bin.
  • foreground - Foreground and text color. Use a symbolic name or a six-character #rrggbb hex code.
  • background - Background color.
  • font - Font.
  • align - Content alignment in the title window. left, center or right.
  • titleWidth - Width of the title window.
  • secondaryAlign - Content alignment in the secondary window. left, center or right.
  • secondaryLines - Amount of lines to show in the secondary window.
  • menu - Menu mode.
  • persist - Keep running for this amount of seconds after the input stream closes.
  • x - X position.
  • y - Y position.
  • lineHeight - Height in pixels of each line. Defaults to the font height + 2px.
  • width - Width.
  • screen - Xinerama screen number.
  • dock - Set to true to dock the window, eg for use as a taskbar or statusbar. Otherwise it'll show on top of other windows.

Stream methods


Set the contents of the title window. Equivalent to stream.write('^tw()' + str).


Toggle collapsed state of the secondary window.


Collapse the secondary window.


"Uncollapse" (expand) the secondary window.


Hide or show the title window.


Hide the title window. If the secondary window is uncollapsed, the secondary window will still be shown.


"Unhide" (show) the title window.


Raise the window in front of all other windows.


Lower the window behind all other windows.


Scroll the secondary window to the top.


Scroll the secondary window to the bottom.


Tell dzen to quit.

Events and actions

This allows you to associate actions to events. Events and actions are separated by = and each pair is separaded by a ;. If an event triggers more than one action, the actions are separated by ,.

For example: entertitle=uncollapse,unhide;button1=exec:xterm:firefox; will uncollapse and unhide the window when the mouse enters the title and will execute xterm and firefox when the mouse button 1 is clicked.

For more information, see the "(2) Option '-e': Events and actions" section of the dzen2 README.

Clickable areas

The ^ca() modifier allows for running commands when the enclosed text is clicked. ^ca(BTN, CMD) marks the beggining of a clickable area which will call CMD when BTN is clicked in it. ^ca() marks the end of the clickable area.

var dzen2 = require('dzen2')
var stream = dzen2()
stream.write('^ca(1, firefox --new-tab me^ca()')

For more information about clickable areas, see the "Interaction" section of the dzen2 README.


When eventServer is set to true, the emit() function will be available inside ^ca().

var dzen2 = require('dzen2')
var stream = dzen2({
  eventServer: true

stream.write('^ca(1, emit(hello))click me^ca()')
stream.on('hello', function () {
  console.log('hello from dzen!')

This internally this starts a tiny TCP server. The emit(event) parts are rewritten to execute a node script that sends the event to the server.

"^ca(1, emit(test-event))Test event^ca()"
// is equivelent to
"^ca(1, /usr/bin/node '/home/username/Projects/dzen2/send-command.js' 41481 'test-event')Test event^ca()"



Current Tags

  • 3.0.0                                ...           latest (4 years ago)

4 Versions

  • 3.0.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (3)
Dev Dependencies (1)
Dependents (1)

Copyright 2014 - 2016 © |