This is a library around Lemonboy's Bar, which lets you easily make use of the great formatting functionalities of the Lemonbar, together with node.js which is ideal for event-based processing.
var lb = require("lemonbar");
lb.launch({
lemonbar: "/usr/bin/lemonbar", // Lemonbar binary
shell: "/bin/sh", // Shell to use for actions
shelloutput: true, // Print shell STDOUT
// More information on the following arguments at https://github.com/LemonBoy/bar#options
background: "#888", // -B Background color (#rgb, #rrggbb, #aarrggbb)
foreground: "#333", // -F Foreground color
lineWidth: 1, lineColor: "#666", // -[Uu] Underline/Overline config
geometry: { // -g Window geometry
x: 0, y: 0,
width: null, height: 50
},
fonts: ["Arial-10", "FontAwesome-10"], // -f Load fonts
bottom: false, // -b Dock bar at bottom instead of top
forceDocking: false, // -d Force docking without asking the window manager
name: null, // -n Set the WM_NAME atom value for the bar
areas: 10 // -a Number of clickable areas
})
Append text to the buffer for the current line.
Send the current line plus text (if given) to Lemonbar, and thus updates the current view.
var lb = require("lemonbar"); lb.launch();
lb.append("Hello World".lbCenter)
lb.write("It's ".lbRight + (" " + new Date().toString() + " ").lbSwap)
Formatting is handled via the String prototype. You have the following helper functions:
Swap the current background and foreground colors.
Aligns the following text to the left side of the screen.
Aligns the following text to the center of the screen.
Aligns the following text to the right side of the screen.
Draw a line under the text.
Draw a line over the text.
Set the text background color. The parameter color has to be a color in one of the formats lemonbar accepts (#rgb
, #rrggbb
, #aarrggbb
).
Set the text foreground color. The parameter color has to be a color in one of the formats lemonbar accepts (#rgb
, #rrggbb
, #aarrggbb
).
Set the font used to draw the following text. The parameter font has to be the exact name (with all XCB parameters) of the font as given in the fonts
lemonbar parameter.
Set the text underline color. The parameter color has to be a color in one of the formats lemonbar accepts (#rgb
, #rrggbb
, #aarrggbb
).
Create a clickable area, when the area is clicked command is sent to shell.
The button field is optional, it defaults to the left button, and it's a number ranging from 1 to 5 which maps to the left, middle, right, scroll up and scroll down movements. Your mileage may vary.
You may want to use the more descriptive values lb.BUTTON_{LEFT|RIGHT|MIDDLE|SCROLLUP|SCROLLDOWN}
.
Nested clickable areas can trigger different commands:
"shutdown".lbAction("poweroff").lbAction("reboot", lb.BUTTON_RIGHT)
Change the monitor the bar is rendered to. monitor can be either:
next
,previous
: Next/previous monitor.first
,last
: First/last monitor.0-9
: Nth monitor.