-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.nezd
553 lines (360 loc) · 18.2 KB
/
README.nezd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
^fg(lightgreen)^r(190x4)^fg(#6fbf47)^r(38x4)^fg(darkgreen)^r(9x4)
^fg(#6fbf47) nezd, (c) 2007 by Robert Manea
^fg(darkgreen)^r(9x4)^fg(#6fbf47)^r(38x4)^fg(lightgreen)^r(190x4)
A general purpose messaging, notification and menu program
The "gadgets" subdirectory contains some tools that you can
use in combination with nezd.
Script archive with a collection of interesting ideas:
^fg(lightblue) http://gotmor.googlepages.com/nezdscriptarchive
^fg(#6fbf47)Features
^fg(#6fbf47)--------
^co(4x4) scriptable in any language
^co(4x4) dynamic colorizer
^co(4x4) icons support
^co(4x4) keyboard support
^co(4x4) single line and/or windows holding multiple lines
^co(4x4) menu functionality
^co(4x4) in-text formating language
^co(4x4) flexible event/action mechanism
^co(4x4) hideable, collapsable
^co(4x4) Xinerama support
^fg(#6fbf47)Requirements
^fg(#6fbf47)------------
In order to build nezd you need the Xlib header files.
^fg(#6fbf47)Installation
^fg(#6fbf47)------------
Edit config.mk to match your local setup (nezd is installed into
the /usr/local namespace by default).
Afterwards enter the following command to build and install nezd (if
necessary as root):
^fg(grey85)make clean install
Optionally if you want to use nezd's gadgets:
^fg(grey85)cd gadgets
^fg(grey85)make clean install
^fg(Khaki)Note: By default nezd will ^fg(red)not^fg(Khaki) be compiled with Xinerama support.
^fg(Khaki)Uncomment the respective lines in config.mk to change this.
^fg(#6fbf47)Contact:
^fg(#6fbf47)--------
Feature requests, patches or anything else related to nezd can be send
to: ^fg(Khaki)rob dot manea at gmail dot com
^fg(#6fbf47)Running nezd
^fg(#6fbf47)------------
nezd accepts a couple of options:
-fg foreground color
-bg background color
-fn font
-ta alignment of title window content
l(eft), c(center), r(ight)
-tw title window width (can be relative with %)
-sa alignment of slave window, see "-ta"
-l lines, ^fg(#6fbf47)see (1)
-e events and actions, ^fg(#6fbf47)see (2)
-m menu mode, ^fg(#6fbf47)see (3)
-p persist EOF (optional timeout in seconds)
-x x position (can be relative with %)
-y y position (can be relative with %)
-h line height (default: fontheight + 2 pixels) (can be relative with %)
-w width (can be relative with %)
-xs number of Xinerama screen
-v version information
^fg(#6fbf47)see (4)^fg(), for the in-text formating language.
^fg(#6fbf47)X resources
^fg(#6fbf47)-----------
Nezd is able to read font and color setting from X resources.
As an example you can add following lines to ~/.Xresources
^fg(Khaki)nezd.font: -*-fixed-*-*-*-*-*-*-*-*-*-*-*-*
^fg(Khaki)nezd.foreground: #22EE11
^fg(Khaki)nezd.background: black
^fg(#6fbf47)Window layout
^fg(#6fbf47)-------------
Nezd's window layout is as follows:
^fg(red) ------------------------------------------
^fg(red) | Title window, single line |
^fg(red) `------------------------------------------´
^fg(#6fbf47) | |
^fg(#6fbf47) | scrollable |
^fg(#6fbf47) | Slave window |
^fg(#6fbf47) | multiple lines |
^fg(#6fbf47) | lines to display simultaneously |
^fg(#6fbf47) | controlled with the |
^fg(#6fbf47) | '-l' option |
^fg(#6fbf47) | |
^fg(#6fbf47) | |
^fg(#6fbf47) `------------------------------------------´
The first line you provide to nezd always goes to the title window,
all other consecutive lines will be drawn to the slave window unless
you explicitly override this with the ^fg(#6fbf47)(4) In-text formating language
^fg()command ^^tw().
^fg(#6fbf47)QA:
^fg(#6fbf47)---
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 ^fg(#6fbf47)(2) Events and actions ^fg()if you'd like to change
this.
Q3: If I echo some text or cat a file nezd closes itself immediately.
A3: There are 2 different approaches nezd uses to terminate itself,
see next section ^fg(#6fbf47)Termination^fg().
Q4: Ok, the title and slave thing works, can I update the
contents of both windows at the same time?
A4: Sure, use the in-text command ^^tw() to explicitly draw to the title window.
See ^fg(#6fbf47)(4) In-Text formating language ^fg()for further details
Q5: Can I change color of my input at runtime?
A5: Yes, you can change both background and foreground colors and
much more See ^fg(#6fbf47)(4) In-Text formating language^fg().
Q6: Can I use nezd as a menu?
A6: Yes, both vertical and horizontal menus are supported.
See ^fg(#6fbf47)(3) Menu ^fg()for further details.
^fg(#6fbf47)Termination:
^fg(#6fbf47)------------
nezd uses two different approaches to terminate itself:
^co(4x4) 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
^co(4x4) Interactive termination: if mouse button3 is clicked -> terminate
- this is the default behaviour, ^fg(#6fbf47)see (2)
- in some modes the Escape key terminates too, ^fg(#6fbf47)see (2)
^fg(#6fbf47)Return values:
^fg(#6fbf47)--------------
0 - nezd received EOF
1 - some error occurred, inspect the error message
user defined - set with 'exit:retval' action, ^fg(#6fbf47)see (2)
^fg(#6fbf47)(1) Option "-l": Slave window
^fg(#6fbf47)--------------------------------
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).
^fg(#6fbf47)(2) Option '-e': Events and actions
^fg(#6fbf47)-----------------------------------
nezd 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 changeable in action.h)
An example:
^fg(grey70) -e 'button1=exec:xterm:firefox;entertitle=uncollapse,unhide;button3=exit'
Meaning:
^fg(grey70)button1=exec:xterm:firefox;
on Button1 event (Button1 press on the mouse) execute xterm and
firefox.
^fg(Khaki)Note: xterm and firefox are options to the exec action
^fg(grey70)entertitle=uncollapse,unhide;
on entertitle (mouse pointer enters the title window) uncollapse
slave window and unhide the title window
^fg(grey70)button3=exit
on button3 event exit nezd
^fg(#6fbf47)Supported events:
^fg(#6fbf47)-----------------
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 (*)
^fg(#6fbf47)(*) Keyboard events:
^fg(#6fbf47)--------------------
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.
^fg(#6fbf47)Supported actions:
^fg(#6fbf47)------------------
exec:command1:..:n execute all given options
menuexec executes selected menu entry
exit:retval exit nezd 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
^fg(Khaki)Note: If no events/actions are specified nezd defaults to:
^fg(#6fbf47)Title only mode:
^fg(#6fbf47)----------------
-e 'button3=exit:13'
^fg(#6fbf47)Multiple lines and vertical menu mode:
^fg(#6fbf47)--------------------------------------
-e 'entertitle=uncollapse,grabkeys;
enterslave=grabkeys;leaveslave=collapse,ungrabkeys;
button1=menuexec;button2=togglestick;button3=exit:13;
button4=scrollup;button5=scrolldown;
key_Escape=ungrabkeys,exit'
^fg(#6fbf47)Horizontal menu mode:
^fg(#6fbf47)---------------------
-e 'enterslave=grabkeys;leaveslave=ungrabkeys;
button4=scrollup;button5=scrolldown;
key_Left=scrollup;key_Right=scrolldown;
button1=menuexec;button3=exit:13
key_Escape=ungrabkeys,exit'
^fg(Khaki)If you define any events/actions, there is no default behaviour,
^fg(Khaki)i.e. you will have to specify _all_ events/actions you want to
^fg(Khaki)use.
^fg(#6fbf47)(3) Option '-m', Menu
^fg(#6fbf47)---------------------
Nezd provides two menu modes, vertical and horizontal menus. You can
access these modes by adding 'v'(ertical) or 'h'(orizontal) to the
'-m' option. If nothing is specified nezd defaults to vertical menus.
Vertical menu, both invocations are equivalent:
^fg(grey70)nezd -p -l 4 -m < file
^fg(grey70)nezd -p -l 4 -m v < file
Horizontal menu:
^fg(grey70)nezd -p -l 4 -m h < file
All actions beginning with "menu" work on the selected menu entry.
^fg(Khaki)Note: Menu mode only makes sense if '-l <n>' is specified!
^fg(Khaki)Horizontal menus have no title window, so all actions
^fg(Khaki)affecting the title window will be silently discarded
^fg(Khaki)in this mode.
^fg(#6fbf47)(4) In-text formating language:
^fg(#6fbf47)-------------------------------
This feature allows to dynamically (at runtime) format the text nezd
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 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
Subject to be improved in the future.
^^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 ^^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)
Giving:
^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 nezd'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 XPM format, see the "bitmaps"
directory for some sample icons. With the standard "bitmap" application
you can easily draw your own icons.
^fg(Khaki)Note: Displaying XPM (pixmap) files imposes a somewhat
^fg(Khaki)higher load than lightweight XBM files, so use
^fg(Khaki)them with care in tight loops.
Doubling the '^^' character removes the special meaning from it.
Some examples:
Input:
^^fg(red)I'm red text ^^fg(blue)I am blue
Resulting in:
^fg(red)I'm red text ^fg(blue)I am blue
Input:
^^bg(#ffaaaa)The ^^fg(yellow)text to ^^bg(blue)^^fg(orange)colorize
Resulting in:
^bg(#ffaaaa)The ^fg(yellow)text to ^bg(blue)^fg(orange)colorize
Input:
^^fg(white)Some text containing ^^^^ characters
Resulting in:
^fg(white)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 battery.
Resulting in:
^i(bitmaps/envelope.xbm) I am an envelope ^fg(yellow)and ^i(bitmaps/battery.xbm) I'm a battery.
Input for rectangles:
6x4 rectangle ^^r(6x4) ^^fg(red)12x8 ^^r(12x8) ^^fg(yellow)and finally 100x15 ^^r(100x15)
Resulting in:
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
Resulting in:
Some text^p(100)^fg(yellow)100 pixels to the right^p(50)^fg(red)50 more pixels to the right
^fg(#6fbf47)Examples:
^fg(#6fbf47)---------
^co(4x4) Display message and timeout after 10 seconds:
^fg(grey85) (echo "This is a message"; sleep 10) | nezd -bg darkred -fg grey85 -fn fixed
^co(4x4) Display message and never timeout:
^fg(grey85) echo "This is a message"| nezd -p
^co(4x4) Display updating single line message:
^fg(grey85) for i in $(seq 1 20); do A=${A}'='; print $A; sleep 1; done | nezd
^co(4x4) Display header and a message with multiple lines:
^fg(grey85) (echo Header; cal; sleep 20) | nezd -l 8
Displays "Header" in the title window and the output of cal in the
8 lines high slave window.
^co(4x4) Display updating messages:
^fg(grey85) (echo Header; while true; do echo test$((i++)); sleep 1; done) | nezd -l 12
The slave window will update contents if new input has arrived.
^co(4x4) Display log files:
^fg(grey85) (su -c "echo LOGFILENAME; tail -f /var/log/messages") | nezd -l 20 -x 100 -y 300 -w 500
^co(4x4) Monthly schedule with remind:
^fg(grey85) (echo Monthly Schedule; remind -c1 -m) | nezd -l 52 -w 410 -p -fn lime -bg '#e0e8ea' -fg black -x 635
^co(4x4) Simple menu:
^fg(grey85) echo "Applications" | nezd -l 4 -p -m < menufile
^co(4x4) Horizontal menu without any files:
^fg(grey85) {echo Menu; echo -e "xterm\nxclock\nxeyes\nxfontsel"} | nezd -l 4 -m h -p
^co(4x4) Extract PIDs from the process table:
^fg(grey85) {echo Procs; ps -a} | nezd -m -l 12 -p \
^fg(grey85) -e 'button1=menuprint;button3=exit;button4=scrollup:3;button5=scrolldown:3;entertitle=uncollapse;leaveslave=collapse' \
^fg(grey85) | awk '{print $1}'
^co(4x4) Nezd as xmonad (see http://xmonad.org) statusbar:
^fg(grey85) status.sh | nezd -ta r -fn '-*-profont-*-*-*-*-11-*-*-*-*-*-iso8859' -bg '#aecf96' -fg black \
^fg(grey85) -p -e 'sigusr1=raise;sigusr2=lower;onquit=exec:rm /tmp/nezd-pid;button3=exit' & echo $! > /tmp/nezd-pid
Have fun.