Lemonbar
b(ar) a(in't) r(ecursive) is a lightweight bar based on XCB. It provides foreground/background color switching along with text alignment and colored under/overlining of text, full utf8 support and reduced memory footprint. Nothing less and nothing more.
Contents
Installation
bar-aint-recursiveAUR is available in the AUR and can be installed manually or through the use of a AUR helper of your choice.
Configuration
Configuration of bar is done at compile time in the file config.h. A default config.h looks like this:
config.h
/* The height of the bar (in pixels) */ #define BAR_HEIGHT 18 /* The width of the bar. Set to -1 to fit screen */ #define BAR_WIDTH -1 /* Offset from the left. Set to 0 to have no effect */ #define BAR_OFFSET 0 /* Choose between an underline or an overline */ #define BAR_UNDERLINE 1 /* The thickness of the underline (in pixels). Set to 0 to disable. */ #define BAR_UNDERLINE_HEIGHT 2 /* Default bar position, overwritten by '-b' switch */ #define BAR_BOTTOM 0 /* The fonts used for the bar, comma separated. Only the first 2 will be used. */ #define BAR_FONT "-*-terminus-medium-r-normal-*-12-*-*-*-c-*-*-1","fixed" /* Some fonts don't set the right width for some chars, pheex it */ #define BAR_FONT_FALLBACK_WIDTH 6 /* Color palette */ #define COLOR0 0x1A1A1A /* background */ #define COLOR1 0xA9A9A9 /* foreground */ #define COLOR2 0x303030 #define COLOR3 0xF92672 #define COLOR4 0xA6E22E #define COLOR5 0xFD971F #define COLOR6 0x66D9EF #define COLOR7 0x9E6FFE #define COLOR8 0xAF875F #define COLOR9 0xCCCCC6
To change the config file, clone the git repository and write the config.h. You can run make
in the directory to make a config.h automatically from the config.def.h
text file. After you're done configuring recompile.
Use an overline instead of an underline
bar
by default supports underlining text with a certain color, but it also supports overlining text instead. To make bar
overline the text replace the 1 with a 0 in the following line
config.h
/* Choose between an underline or an overline */ #define BAR_UNDERLINE 0
Change location of the bar
bar
can be placed at the top or the bottom of the screen. It defaults to be on the top. To get bar
on the bottom, edit the following lines in config.h
or use the option -b at runtime.
config.h
/* Default bar position, overwritten by '-b' switch */ #define BAR_BOTTOM 1
Change the font
bar
does not support image files per se, but it does support bitmap fonts that allows you to use a font with icons such as stlarch_fontAUR. To use such a font, install the font and edit config.h
accordingly. The below example shows how to change the bar font to use stlarch
.
config.h
/* The fonts used for the bar, comma separated. Only the first 2 will be used. */ #define BAR_FONT "-misc-stlarch-medium-*-normal-*-10-*-*-*-c-*-*-1","fixed"
Colors
Lastly bar
supports the use of up to ten colors. These are defined at the bottom config.h
. The colors are defined in a hexadecimal format. The last six characters in each of the color lines define the color. For example would the following code change the 6th color(COLOR6
to black(000000).
config.h
#define COLOR6 0x000000
Usage
Bar prints no information on its own. To get any text into bar
you need to pipe text into it. The following example would write the text "Hello World" into your bar.
#!/bin/bash # Echo the text echo "Hello World"
If you want the text in bar
to update through a script, you need to add the -p option.
Colors
bar
uses the following commands to color the text, background or the under/overline.
Command | Description |
---|---|
\f# | uses the # color as the font's color. |
\b# | Uses the # color as the background |
\u# | Uses the # color for under/overlining the text. |
Text alignment
bar
also supports alignment of text. It uses the following commands to align the text
Distro | Color |
---|---|
\l | Aligns the text to the left |
\c | Aligns the text to the center |
\r | Aligns the text to the right |
Examples
The following example prints the date and time in the middle of the bar underlined by COLOR6, the font's color being COLOR1 and the background COLOR0 and changes the underline back to the backgrounds color afterwards. Run it with /path/to/script/example.sh | bar -p
example.sh
#!/bin/bash # Define the clock Clock() { DATE=$(date "+%a %b %d, %T") echo -n "$DATE" } # Print the clock while true; do echo "\c\f1\b0\u6 $(Clock)\ur" sleep 1; done
Another example showing the battery percentage. To use this script you need to install acpi.
example.sh
#!/bin/bash #Define the battery Battery() { BATPERC=$(acpi --battery | awk -F, '{print $2}') echo "$BATPERC" } # Print the percentage while true; do echo "\r$(Battery)" sleep 1; done