2 -- Copyright (c) 2007, Bart Trojanowski <bart@jukie.net>
4 -- Notification area for wmii bar
6 -- To get a messages use:
8 -- wmiir xwrite /event msg anything you want to see
10 -- If you have a script that seldom generates one-line events, you can run:
12 -- somescript | sed -u 's/^/msg /' | wmiir write /event
14 -- ssh remote tail -F log-file | xargs -n1 -i wmiir xwrite /event "msg {}"
17 local wmii
= require("wmii")
18 local os
= require("os")
19 local math
= require("math")
20 local string = require("string")
21 local tostring = tostring
29 local color_start
= {{0xFF,0xFF,0xFF}, {0xAA,0x22,0xAA}, {0xFF,0x00,0x00}}
30 local color_end
= {{0x44,0x44,0x44}, {0x22,0x22,0x22}, {0x33,0x33,0x33}}
31 local color_steps
= 10
33 -- build up the colours palett
35 for i
=1,color_steps
do
38 local s
=color_start
[t
]
42 local d
= (e
[r
] - s
[r
]) / color_steps
43 local c
= math
.floor(s
[r
] + (i
* d
))
44 x
= x
.. string.format("%02x", c
)
51 -- get a widget; 0 is the first location in the /rbar, so the middle
52 local widget
= wmii
.widget
:new ("0")
54 -- function that cycles the colours
55 local timer
= wmii
.timer
:new (function (time_since_update
)
56 color_index
= color_index
+ 1
57 if not colors
[color_index
] then
61 widget
:show (nil, colors
[color_index
])
65 -- finally, an event we can listen for
66 wmii
.add_event_handler ("msg", function (ev
, args
)
67 wmii
.log("msg: " .. tostring(args
))
71 widget
:show (tostring(args
), colors
[color_index
])