# Lemonbuddy [![Build Status](https://travis-ci.org/jaagr/lemonbuddy.svg?branch=master)](https://travis-ci.org/jaagr/lemonbuddy) [![MIT License](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000?style=plastic)](https://github.com/jaagr/lemonbuddy/blob/master/LICENSE) A fast and easy-to-use tool for generating status bars. **Lemonbuddy** aims to help users build beautiful and highly customizable status bars for their desktop environment, without the need of having a black belt in shell scripting. Heres a few screenshots showing you what it can look like: [![sample screenshot](http://i.imgur.com/xvlw9iHt.png)](http://i.imgur.com/xvlw9iH.png) [![sample screenshot](http://i.imgur.com/cYQOuRrt.png)](http://i.imgur.com/cYQOuRr.png) [![sample screenshot](http://i.imgur.com/A6spiZZt.png)](http://i.imgur.com/A6spiZZ.png) [![sample screenshot](http://i.imgur.com/TY5a5r9t.png)](http://i.imgur.com/TY5a5r9.png) Please note that the project still is in early development, so please report any problems by [creating an issue ticket](https://github.com/jaagr/lemonbuddy/issues/new). ## Table of Contents * [Introduction](#introduction) * [Getting started](#getting-started) * [Dependencies](#dependencies) * [Building from source](#building-from-source) * [Running](#running) * [Launching the bar in your wm's bootstrap routine](#launching-the-bar-in-your-wms-bootstrap-routine) * [Configuration](#configuration) * [Fonts](#fonts) * [Syntax and DSL](#syntax-and-dsl) * [Application settings](#application-settings) * [Bar settings](#bar-settings) * [Modules](#modules) * [internal/backlight](#module-internalbacklight) * [internal/battery](#module-internalbattery) * [internal/bspwm](#module-internalbspwm) * [internal/cpu](#module-internalcpu) * [internal/date](#module-internaldate) * [internal/i3](#module-internali3) * [internal/memory](#module-internalmemory) * [internal/mpd](#module-internalmpd) * [internal/network](#module-internalnetwork) * [internal/volume](#module-internalvolume) * [custom/menu](#module-custommenu) * [custom/script](#module-customscript) * [custom/text](#module-customtext) * [Example configurations](#example-configurations) * [License](#license) ## Introduction The main purpose of **Lemonbuddy** is serve as content generator for status bars. It has built-in functionality to generate output for the most commonly used widgets, such as: - Playback controls and status display for [MPD](https://www.musicpd.org/) using [libmpdclient](https://www.musicpd.org/libs/libmpdclient/) - [ALSA](http://www.alsa-project.org/main/index.php/Main_Page) volume controls - Workspace and desktop panel for [bspwm](https://github.com/baskerville/bspwm) and [i3](https://github.com/i3/i3) - CPU and memory load indicator - Battery display - Network connection details - Backlight level - Date and time label - Time-based shell script execution - Command output tailing - User-defined menu tree - And more... Each bar contains a set of modules, which in turn defines a set of formatting rules and options. Read more about [how the configuration works](#configuration). The project was developed specifically for Lemonbar, and the initial plan was to integrate a trimmed down version of it into Lemonbuddy. This would remove the need of having to pass data back and forth between the two processes. After spending time trying to create an interface to the Lemonbar source code, I decided to not use it at all. Lemonbar is a great application but it would be more efficient to write a custom X rendering implementation instead of trying to patch up Lemonbar. Not only does it fix the *"Lemonbuddy doesn't work with my extra-custom-lemonbar-fork"* issue, it also makes it alot easier to implement new features... The performance boost is of course also welcome to join the party, so that's nice. The new implementation will use the same `%{...}` syntax Lemonbar uses, which means that existing configurations will still work, so keep ricing. ## Getting started If you are using **Arch Linux**, you can install the AUR package [lemonbuddy-git](https://aur.archlinux.org/packages/lemonbuddy-git/) to get the latest version, or [lemonbuddy](https://aur.archlinux.org/packages/lemonbuddy/) for the latest stable release. For **Void Linux** users, the application can be installed using XBPS: `xbps-install -S lemonbuddy`. If you create a package for any other distribution, please consider contributing the template so that we can make the application available for more people. ### Dependencies A C++ compiler with C++14 support. For example [`clang`](http://clang.llvm.org/get_started.html). - lemonbar with xft support _(personally I use [this fork](https://github.com/osense/bar))_ - cmake - boost - libxcb - xcb-proto Optional dependencies for module support: - wireless_tools (required for `internal/network` support) - alsa-lib (required for `internal/volume` support) - libmpdclient (required for `internal/mpd` support) - jsoncpp, libsigc++ (required for `internal/i3` support) ~~~ sh $ pacman -S cmake boost libxcb xcb-proto wireless_tools alsa-lib libmpdclient jsoncpp libsigc++ $ xbps-install cmake boost-devel libxcb-devel alsa-lib-devel i3-devel libmpdclient-devel jsoncpp-devel libsigc++-devel wireless_tools-devel $ apt-get install cmake libxcb1-dev xcb-proto python-xcbgen libboost-dev libiw-dev libasound2-dev libmpdclient-dev libjsoncpp-dev libsigc++-dev ~~~ ### Building from source Please [report any problems](https://github.com/jaagr/lemonbuddy/issues/new) you run into when building the project. It helps alot. ~~~ sh $ git clone --branch 1.4.6 --recursive https://github.com/jaagr/lemonbuddy $ mkdir lemonbuddy/build $ cd lemonbuddy/build $ cmake .. $ sudo make install ~~~ ## Running Before customizing the bar, make sure everything works as expected by trying out one of the example configurations installed with the application. The following code will get you started: ~~~ sh # Create the config root directory $ mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/lemonbuddy $ cd ${XDG_CONFIG_HOME:-$HOME/.config}/lemonbuddy # Copy sample config for the running wm (uses a wm agnostic config as fallback) $ __wm=$(pgrep -l -x "(bspwm|i3)"); __prefix=$(which lemonbuddy) $ cp "${__prefix%%/bin*}/share/examples/lemonbuddy/config${__wm:+.${__wm##* }}" config # Launch the bar # (where "example" is the name of the bar as defined by [bar/NAME] in the config) $ lemonbuddy_wrapper example ~~~ > **NOTE:** If you are running i3 or bspwm and you don't see the workspace icons > it probably depends on the font. Install `font-awesome` and relaunch the bar. > ...or replace the icons in the config. **It is recommended** to always use `lemonbuddy_wrapper` when launching the bars. `lemonbuddy_wrapper` is just a simple shell script that takes care of redirecting the in-/output streams between `lemonbuddy` and `lemonbar`. If you handle the in-/output stream redirection's manually, the internal command handlers (e.g. mpd or volume controls) might stop working. It won't change the output of the bar but you will miss out on the internal API calls, which is one of the main advantages of using the application. The `lemonbuddy_wrapper` will be deprecated once `lemonbar` is integrated into the project. ## Launching the bar in your wm's bootstrap routine When using the wrapper to start the bar in in your wm's autostart routine, make sure to include a kill directive before launching the bar. This is done to make sure that any previously spawned processes gets terminated before before we launch the new ones. Create an executable file containing the startup logic, for example `$HOME/.config/lemonbuddy/launch.sh`: ~~~ sh #!/usr/bin/env sh # Terminate already running bar instances lemonbuddy_terminate noconfirm # Launch bar1 and bar2 lemonbuddy_wrapper bar1 & lemonbuddy_wrapper bar2 & echo "Bars launched..." ~~~ Make it executable: ~~~ sh $ chmod +x $HOME/.config/lemonbuddy/launch.sh ~~~ If you are using **bspwm**, add the following line to `bspwmrc`: ~~~ sh $HOME/.config/lemonbuddy/launch.sh ~~~ If you are using **i3**, add the following line to your configuration: ~~~ sh exec_always $HOME/.config/lemonbuddy/launch.sh ~~~ ## Configuration The configuration syntax is a work in progress. Please [create an issue ticket](https://github.com/jaagr/lemonbuddy/issues/new) and let me know how you think we can improve it. The values used in the examples below are to be considered placeholder values, and the resulting output might not be award-winning. ### Fonts When working with unicode symbols, remember that fonts render the symbols differently. Changing font can drastically improve the quality of your bar. One must-have font is [Unifont](http://unifoundry.com/unifont.html), which has great unicode coverage. Also try different icon fonts, such as [Font Awesome](http://fontawesome.io/icons/) and [Material Icons](https://design.google.com/icons/). *TODO: Describe usage in configuration...* ### Syntax and DSL *TODO: Clarify...* The configuration syntax is based on the `ini` file format. ~~~ ini [section/name] str = My string ; Hint: Quote the value to keep the spaces str = " My string" bool = true bool = on int = 10 float = 10.0 ; Values for a defined bar can be referenced using: key = ${bar/top.foreground} ; Values for the current bar can be referenced using: key = ${BAR.foreground} ; Other values can be referenced using: key = ${section.key} ; Environment variables can be referenced using: key = ${env:VAR_NAME} ~~~ ~~~ ini [section/name] ; Most modules define a format-N field ; For example, the mpd module defines the following formats: ; format-online = ... ; format-offline = ... ; ; Each format exposes the following fields: ; format[-NAME]-padding = N (unit: whitespaces) ; format[-NAME]-margin = N (unit: whitespaces) ; (See "Bar settings" for more details on "spacing") ; format[-NAME]-spacing = N (unit: whitespaces) ; (This value will displace the format block horizontally by +/-N pixels) ; format[-NAME]-offset = N (unit: pixels) ; format[-NAME]-foreground = #aa[rrggbb] ; format[-NAME]-background = #aa[rrggbb] ; format[-NAME]-underline = #aa[rrggbb] ; ^ ; | the underline and overline color is always the same ; v ; format[-NAME]-overline = #aa[rrggbb] ; ; The rest of the drawtypes follow the same pattern. ; ; label-NAME[-(foreground|background|(under|over)line|font|padding|maxlen|ellipsis)] = ? ; icon-NAME[-(foreground|background|(under|over)line|font|padding)] = ? ; ramp-NAME-[0-9]+[-(foreground|background|(under|over)line|font|padding)] = ? ; animation-NAME-[0-9]+[-(foreground|background|(under|over)line|font|padding)] = ? ; ; bar-NAME-width = N (unit: characters) ; bar-NAME-format = (tokens: %fill% %indicator% %empty%) ; bar-NAME-foreground-[0-9]+ = #aarrggbb ; bar-NAME-indicator[-(foreground|background|(under|over)line|font|padding)] = ; bar-NAME-fill[-(foreground|background|(under|over)line|font|padding)] = ; bar-NAME-empty[-(foreground|background|(under|over)line|font|padding)] = ; ; Example: ; format-online = format-offline = format-offline-offset = -8 ; Cap the song label without trailing ellipsis label-song-maxlen = 30 label-song-ellipsis = false ; By only specifying alpha value, it will be applied to the bar's default foreground label-time-foreground = #66 label-offline =  mpd is off label-offline-foreground = #66 icon-play =  icon-pause =  icon-stop =  bar-progress-width = 30 bar-progress-indicator = | bar-progress-fill = █ bar-progress-empty = █ bar-progress-empty-foreground = #44 ~~~ ### Application settings ~~~ ini [settings] ; Limit the amount of events sent to lemonbar within a set timeframe: ; - "Allow updates within of time" ; Default values: throttle_limit = 5 throttle_ms = 50 ~~~ ### Bar settings ~~~ ini [bar/example] ; Use the following command to list available outputs: ; $ xrandr -q | grep " connected" | cut -d ' ' -f1 monitor = HDMI1 ; Omit the % to specify the width in pixels width = 100% height = 30 ; Offset value defined in pixels offset_x = 0 offset_y = 0 ; Put the bar at the bottom of the screen bottom = true ; Weather to force docking mode or not dock = false ; This value is used as a multiplier when adding spaces between elements spacing = 3 ; Height of under-/overline lineheight = 14 ; Colors background = #222222 foreground = #eefafafa linecolor = ${bar/example.background} ; Amount of spaces to add at the start/end of the whole bar padding_left = 5 padding_right = 2 ; Amount of spaces to add before/after each module module_margin_left = 3 module_margin_right = 3 ; Fonts are defined using: ; font-0 = NotoSans-Regular:size=8;0 font-1 = MaterialIcons:size=10;0 font-2 = Termsynu:size=8;-1 font-3 = FontAwesome:size=10;0 ; The separator will be inserted between the output of each module separator = | ; This value is used by Lemonbar and it specifies the clickable ; areas available -> %{A:action:}...%{A} clickareas = 30 ; Value to be used to set the WM_NAME atom ; This defaults to "lemonbuddy-[BAR]_[MONITOR]" wm_name = mybar ; Locale used to localize module output (for example date) ;locale = sv_SE.UTF-8 ; Define what modules to output modules-left = cpu ram modules-center = label modules-right = clock ~~~ ### Modules #### Module `internal/backlight` ~~~ ini [module/backlight] type = internal/backlight ; Use the following command to list available cards: ; $ ls -1 /sys/class/backlight/ card = intel_backlight ~~~ ##### Extra formatting (example) ~~~ ini ; Available tags: ;