Package: lemonbar
Lemonbar APIGoalProvide a simple to use, modern asynchronous Pythonic API forLemonbar.Grow upon the primitives that Lemonbar provides, to provide the end-user
of this library with extensive features.Getting StartedTODOHow to useCreating a Lemonbar instance.Firstly, you must create an instance of the Lemonbar class.This class manages the low-level interactions with Lemonbar CLI and
abstracts them for you.fromlemonbarimportLemonbarfromlemonbar.modelsimportBarGeometryfromlemonbar.models.bar_placementimportBarPlacementasyncdefmain():lemonbar=Lemonbar([# modules... (Talked about later)],geometry=BarGeometry.build(height=50),placement=BarPlacement.BOTTOM,background_color="#111111",foreground_color="#B2B2B2",underline_color="#D8AD4C")lemonbar.open()awaitlemonbar.attach()Above, you see how you create the Lemonbar instance.As you can see all the passing of CLI arguments is abstracted away from you
in a nice and clean fashion. To add on to that, all types passed are validated
using Pydantic - Including colors and screen outputs.
Unfortunately, validation could not be made for font names.ArgumentsDefault values are passed according to Lemonbar specification.All you need to do to have Lemonbar running is define modules!modules: List[Module]Modules are an interface that theLemonbarclass knows how to communicate with.They allow you to efficiently render data on to a bar.geometry: BarGeometry = NoneAllows you to define the size and offsets of the bar on the screen.outputs: Optional[List[MonitorId]] = NoneAllows you to define the monitors which you'd like the Lemonbar to be
displayed on. If nothing is passed, it will display on all screens.placement: BarPlacement = BarPlacement.TOPAllows you to define whether you want the bar to be placed on the top
of your screen or on the bottom.force_dock: bool = FalseForce docking without asking the window manager.
This is needed if the window manager isn't EWMH compliant.fonts: Optional[List[str]] = NoneDefine the font to load into one of the five slots
See:Lemonbar Optionspermanent: bool = FalseMake the bar permanent, don't exit after the standard input is closed.title: Optional[str] = ""Defines the WM_NAME of the bar. Meaning the title of the window.underline_width: int = 1Sets the underline width in pixels. The default is 1.background_color: Optional[str] = NoneSet the background color of the bar.Since Pydantic is used, any of the following is valid:Pydantic Color Extensionname (e.g. "Black", "azure")hexadecimal value (e.g. "0x000", "#FFFFFF", "7fffd4")RGB/RGBA tuples (e.g. (255, 255, 255), (255, 255, 255, 0.5))RGB/RGBA strings (e.g. "rgb(255, 255, 255)", "rgba(255, 255, 255, 0.5)")HSL strings (e.g. "hsl(270, 60%, 70%)", "hsl(270, 60%, 70%, .5)")foreground_color: Optional[str] = NoneSame as background color but for the foreground.underline_color: Optional[str] = NoneSame as background color but for underlines.logger: logging.Logger = _DEFAULT_LOGGERThe logger the Lemonbar class should use when logging information about
the execution of modules.ModulesA module is simply a class which defines the following:What string to renderWhen to renderHow to handle events (stdout from Lemonbar)When to handle eventsSee one of the predefined modules for an example.For example:ClockModules also have the option to define aModule Configuration, a configuration
is made up of the following fields:minimum_render_interval: datetime.timedelta = datetime.timedelta(seconds=1)The minimum amount of time to wait before callingrender()on the
module again.This is a guarantee that afterat leasttimedelta, in the
next render cycle, therendermethod is called.force_render_on_event: bool = TrueAllows you to overrideminimum_render_intervalif the module processed an event. Meaning, ifminimum_render_intervalhas not
passed but the module processed an event,renderwill be called.cache_exceptions: bool = TrueIf true and an exception is raised in the module,
do not try immediately on the next render cycle to re-render but
waitminimum_render_interval.FormattersThis library also provides formatters for those definedhereunder
theformatterspackage.You are more than welcome to take a look at it!