Text Widget
The text widget is the most common widget, it is used to display any (static or dynamic) text or numbers.
A fully-featured Text widget looks like this:
Widget 'name' { class 'Text' expression <expr1> prefix <expr2> postfix <expr3> width <number> align <char> style <string> foreground <color> background <color> speed <number> update <number> }
Parameters:
expression | this expression will be evaluated and its result will be displayed. |
prefix, postfix | the result of these expressions will be displayd before/after the actual value |
width | length of the whole widget (including prefix and postfix!) |
precision | (maximum) number of decimal places |
align | either of 'L' (left, the default), 'C' (center), 'R' (right), 'M' (marquee), 'A' (automatic marquee), 'PL' (pingpong scrolling, short strings are left-aligned), 'PC' (pingpong scrolling, short strings are centered) or 'PR' (pingpong scrolling, short strings are right-aligned) |
style | text style, 'bold' for bold text, everything else is normal text (graphic displays only) |
foreground | color of active pixels (RRGGBBAA or RRGGBB), default is opaque black '000000ff' (see colors for details) |
background | color of inactive pixels (RRGGBBAA or RRGGBB), default is transparent 'ffffff00' (see colors for details) |
speed | marquee scroller interval (msec), default 500msec |
update | update interval (msec), default: 1000 msec (1 sec), 0 (zero) means never (for static text) |
'align A' available in version 0.10.2 'align P_' available in version 0.11.0
You may ask why prefix and postfix are expressions, too, and not just static strings? Well, the answer is simple: It gives you maximum flexibility! Think of a widget load_avg, which should display the average system load, but append an exclamation mark if the load is greater than 2:
Widget loadavg { class 'Text' expression loadavg(1) prefix 'Load' postfix loadavg(1) > 2.0 ? '!' : ' ' width 10 precision 1 align 'R' update 200 }
Alignment
Note that only the actual value is aligned as you specifiy with the align parameter. Prefix is always left-aligned, and postfix always right-aligned! If you use the marquee scroller (align 'M'), prefix, actual value and postfix are simply concatenated together, and the resulting string is displayed in a circular manner, stepping one char every speed msec.
Precision
If you omit the precision parameter, LCD4Linux treats the expression result as a string, and displays it as is.
If you specify a precision, the value is converted to a floating point number, and displayed with the specified number of decimal places. If the number does not fit into the available space (which is width - length(prefix) - length(postfix)), decimal places are cut off from the right until there's enough space. If the last decimal digit has been cut off, the decimal point is omitted, too. If the value still does not fit, it is displayed as a number of asterisks '*')
So there's a big difference between precision 0 and no precision at all!
Let me rephrase that: If you want a expression to be displayed as a string, do not specify a precision! Otherwise LCD4Linux tries to convert the string into a number!