1 About

xmobar is a minimalistic, mostly text based, status bar. It was originally designed and implemented by Andrea Rossato to work with xmonad, but it's actually usable with any window-manager.

xmobar was inspired by the Ion3 status bar, and supports similar features, like dynamic color management, icons, output templates, and extensibility through plugins.

This page documents xmobar 0.22.1 (see release notes).

This screenshot shows xmobar running under sawfish, with antialiased fonts. And this one is my desktop with xmonad and two instances of xmobar.

2 Bug Reports

To submit bug reports you can use the bug tracker over at Github or send mail to our Mailing list.

Note: the old bug tracker at Google code is deprecated. Please use Github's for new bugs.

3 Installation

3.1 Using cabal-install

Xmobar is available from Hackage, and you can install it using cabal-install:

    cabal install xmobar

See below for a list of optional compilation flags that will enable some optional plugins. For instance, to install xmobar with all the bells and whistles, use:

    cabal install xmobar --flags="all_extensions"

3.2 From source

If you don't have cabal-install installed, you can get xmobar's source code in a variety of ways:

If you have cabal installed, you can now use it from within xmobar's source tree:

    cabal install -fall_extensions

Otherwise, run the configure script:

    runhaskell Setup.lhs configure

    # To enable UTF-8 support run:
    runhaskell Setup.lhs configure --flags="with_utf8"

    # To enable both XFT and UTF-8 support run:
    runhaskell Setup.lhs configure --flags="with_xft"

    # To enable all extensions
    runhaskell Setup.lhs configure --flags="all_extensions"

Now you can build the source:

    runhaskell Setup.lhs build
    runhaskell Setup.lhs install # possibly to be run as root

3.3 Optional features

You can configure xmobar to include some optional plugins and features, which are not compiled by default. To that end, you need to add one or more flags to either the cabal install command or the configure setup step, as shown in the examples above.

Extensions need additional libraries (listed below) that will be automatically downloaded and installed if you're using cabal install. Otherwise, you'll need to install them yourself.

with_dbus

Enables support for DBUS by making xmobar to publish a service on the session bus. Requires the dbus package.

with_threaded

Uses GHC's threaded runtime. Use this option if xmobar enters a high-CPU regime right after starting.

with_utf8

UTF-8 support. Requires the utf8-string package.

with_xft

Antialiased fonts. Requires the X11-xft package. This option automatically enables UTF-8.

To use XFT fonts you need to use the xft: prefix in the font configuration option. For instance:

font = "xft:Times New Roman-10:italic"

Or to have fallback fonts, just separate them by commas:

font = "xft:Open Sans:size=9,WenQuanYi Zen Hei:size=9"
with_mpd

Enables support for the MPD daemon. Requires the libmpd package.

with_mpris

Enables support for MPRIS v1/v2 protocol. Requires the dbus and text packages.

with_inotify

Support for inotify in modern Linux kernels. This option is needed for the MBox and Mail plugins to work. Requires the hinotify package.

with_iwlib

Support for wireless cards. Enables the Wireless plugin. No Haskell library is required, but you will need the iwlib C library and headers in your system (e.g., install libiw-dev in Debian-based systems).

with_alsa

Support for ALSA sound cards. Enables the Volume plugin. Requires the alsa-mixer package. To install the latter, you'll need the libasound C library and headers in your system (e.g., install libasound2-dev in Debian-based systems).

with_datezone

Support for other timezones. Enables the DateZone plugin. Requires timezone-olson and timezone-series package.

with_xpm

Support for xpm image file format. This will allow loading .xpm files in <icon>. Requires the libXpm C library.

all_extensions

Enables all the extensions above.

4 Running xmobar

You can now run xmobar with:

    xmobar /path/to/config &

or

    xmobar &

if you have the default configuration file saved as $XDG\_CONFIG\_HOME/xmobar/xmobarrc (defaulting to ~/.config/xmobar/xmobarrc), or ~/.xmobarrc.

4.1 Signal Handling

Since 0.14 xmobar reacts to SIGUSR1 and SIGUSR2:

5 Configuration

5.1 Quick Start

See samples/xmobar.config for an example.

For the output template:

and receives on standard input the line

```<action=`echo test` button=1><raw=41:<action=`echo mooo`

button=1>foo/>```

then it will display the text <action=`echo mooo` button=1>foo</action>, which, when clicked, will cause test to be echoed.

Other configuration options:

font

Name of the font to be used. Use the xft: prefix for XFT fonts.

bgColor

Background color.

fgColor

Default font color.

position

Top, TopP, TopW, TopSize, Bottom, BottomP, BottomW, BottomSize or Static (with x, y, width and height).

TopP and BottomP take 2 arguments: left padding and right padding.

TopW and BottomW take 2 arguments: an alignment parameter (L for left, C for centered, R for Right) and an integer for the percentage width xmobar window will have in respect to the screen width.

TopSize and BottomSize take 3 arguments: an alignment parameter, an integer for the percentage width, and an integer for the minimum pixel height that the xmobar window will have.

For example:

   position = BottomW C 75

to place xmobar at the bottom, centered with the 75% of the screen width.

Or:

   position = BottomP 120 0

to place xmobar at the bottom, with 120 pixel indent of the left.

Or

   position = Static { xpos = 0 , ypos = 0, width = 1024, height = 15 }

or

  position = Top
lowerOnStart

When True the window is sent the bottom of the window stack initially.

hideOnStart

When set to True the window is initially not mapped, i.e. hidden. It then can be toggled manually (for example using the dbus interface) or automatically (by a plugin) to make it reappear.

allDesktops

When set to True (the default), xmobar will tell the window manager explicitly to be shown in all desktops, by setting _NET_WM_DESKTOP to 0xffffffff.

overrideRedirect

If you're running xmobar in a tiling window manager, you might need to set this option to False so that it behaves as a docked application. Defaults to True.

pickBroadest

When multiple displays are available, xmobar will choose by default the first one to place itself. With this flag set to True (the default is False) it will choose the broadest one instead.

persistent

When True the window status is fixed i.e. hiding or revealing is not possible. This option can be toggled at runtime. Defaults to False.

border

TopB, TopBM, BottomB, BottomBM, FullB, FullBM or NoBorder (default).

TopB, BottomB, FullB take no arguments, and request drawing a border at the top, bottom or around xmobar's window, respectively.

TopBM, BottomBM, FullBM take an integer argument, which is the margin, in pixels, between the border of the window and the drawn border.

borderColor

Border color.

borderWidth

Border width in pixels.

iconRoot

Root folder where icons are stored. For if path start with "/", "./" or "../" it is interpreted as it is. Otherwise it will have iconRoot ++ "/" prepended to it. Default is ".".

commands

For setting the options of the programs to run (optional).

sepChar

The character to be used for indicating commands in the output template (default '%').

alignSep

a 2 character string for aligning text in the output template. The text before the first character will be align to left, the text in between the 2 characters will be centered, and the text after the second character will be align to the right.

template

The output template.

5.1.1 Running xmobar with i3status

xmobar can be used to display information generated by i3status, a small program that gathers system information and outputs it in formats suitable for being displayed by the dzen2 status bar, wmii's status bar or xmobar's StdinReader. See i3status manual for further details.

5.2 Command Line Options

xmobar can be either configured with a configuration file or with command line options. In the second case, the command line options will overwrite the corresponding options set in the configuration file.

Example:

xmobar -B white -a right -F blue -t '%LIPB%' -c '[Run Weather "LIPB" [] 36000]'

This is the list of command line options (the output of xmobar --help):

Usage: xmobar [OPTION...] [FILE]
Options:
  -h, -?        --help                 This help
  -V            --version              Show version information
  -f font name  --font=font name       The font name
  -B bg color   --bgcolor=bg color     The background color. Default black
  -F fg color   --fgcolor=fg color     The foreground color. Default grey
  -o            --top                  Place xmobar at the top of the screen
  -b            --bottom               Place xmobar at the bottom of the screen
  -d            --dock                 Try to start xmobar as a dock
  -a alignsep   --alignsep=alignsep    Separators for left, center and right text
                                       alignment. Default: '}{'
  -s char       --sepchar=char         The character used to separate commands in
                                       the output template. Default '%'
  -t template   --template=template    The output template
  -i path       --iconroot=path        Default directory for icon pattern files
  -c commands   --commands=commands    The list of commands to be executed
  -C command    --add-command=command  Add to the list of commands to be executed
  -x screen     --screen=screen        On which X screen number to start

Mail bug reports and suggestions to <xmobar@projects.haskell.org>

5.3 The DBus Interface

When compiled with the optional with_dbus flag, xmobar can be controlled over dbus. All signals defined in src/Signal.hs as data SignalType can now be sent over dbus to xmobar. Due to current limitations of the implementation only one process of xmobar can acquire the dbus. This is handled on a first-come-first-served basis, meaning that the first process will get the dbus interface. Other processes will run without further problems, yet have no dbus interface.

An example using the dbus-send command line utility:

    dbus-send \
        --session \
        --dest=org.Xmobar.Control \
        --type=method_call \
        --print-reply \
        '/org/Xmobar/Control' \
        org.Xmobar.Control.SendSignal \
        "string:Toggle"

It is also possible to send multiple signals at once:

    # send to another screen, reveal and toggle the persistent flag
    dbus-send [..] \
        "string:ChangeScreen" "string:Reveal 0" "string:TogglePersistent"

5.3.1 Example for using the DBus IPC interface with XMonad

Bind the key which should {,un}map xmobar to a dummy value. This is necessary for {,un}grabKey in xmonad.

((0, xK_Alt_L   ), return ())

Also, install avoidStruts layout modifier from XMonad.Hooks.ManageDocks

Finally, install these two event hooks (handleEventHook in XConfig) myDocksEventHook is a replacement for docksEventHook which reacts on unmap events as well (which docksEventHook doesn't).

import qualified XMonad.Util.ExtensibleState as XS

data DockToggleTime = DTT { lastTime :: Time } deriving (Eq, Show, Typeable)

instance ExtensionClass DockToggleTime where
    initialValue = DTT 0

toggleDocksHook :: Int -> KeySym -> Event -> X All
toggleDocksHook to ks ( KeyEvent { ev_event_display = d
                                 , ev_event_type    = et
                                 , ev_keycode       = ekc
                                 , ev_time          = etime
                                 } ) =
        io (keysymToKeycode d ks) >>= toggleDocks >> return (All True)
    where
    toggleDocks kc
        | ekc == kc && et == keyPress = do
            safeSendSignal ["Reveal 0", "TogglePersistent"]
            XS.put ( DTT etime )
        | ekc == kc && et == keyRelease = do
            gap <- XS.gets ( (-) etime . lastTime )
            safeSendSignal [ "TogglePersistent"
                           , "Hide " ++ show (if gap < 400 then to else 0)
                           ]
        | otherwise = return ()

    safeSendSignal s = catchX (io $ sendSignal s) (return ())
    sendSignal    = withSession . callSignal
    withSession mc = connectSession >>= \c -> callNoReply c mc >> disconnect c
    callSignal :: [String] -> MethodCall
    callSignal s = ( methodCall
                     ( objectPath_    "/org/Xmobar/Control" )
                     ( interfaceName_ "org.Xmobar.Control"  )
                     ( memberName_    "SendSignal"          )
                   ) { methodCallDestination = Just $ busName_ "org.Xmobar.Control"
                     , methodCallBody        = map toVariant s
                     }

toggleDocksHook _ _ _ = return (All True)

myDocksEventHook :: Event -> X All
myDocksEventHook e = do
    when (et == mapNotify || et == unmapNotify) $
        whenX ((not `fmap` (isClient w)) <&&> runQuery checkDock w) refresh
    return (All True)
    where w  = ev_window e
          et = ev_event_type e

5.4 The Output Template

The output template must contain at least one command. xmobar will parse the template and will search for the command to be executed in the commands configuration option. First an alias will be searched (plugins such as Weather or Network have default aliases, see below). After that, the command name will be tried. If a command is found, the arguments specified in the commands list will be used.

If no command is found in the commands list, xmobar will ask the operating system to execute a program with the name found in the template. If the execution is not successful an error will be reported.

It's possible to insert in the global templates icon directives of the form:

 <icon=/path/to/bitmap.xbm/>

which will produce the expected result. Accepted image formats are XBM and XPM (when with_xpm flag is enabled). If path does not start with "/", "./", "../" it will have iconRoot ++ "/" prepended to it.

It's also possible to use action directives of the form:

 <action=`command` button=12345>

which will be executed when clicked on with specified mouse buttons. This tag can be nested, allowing different commands to be run depending on button clicked.

5.5 The commands Configuration Option

The commands configuration option is a list of commands information and arguments to be used by xmobar when parsing the output template. Each member of the list consists in a command prefixed by the Run keyword. Each command has arguments to control the way xmobar is going to execute it.

The option consists in a list of commands separated by a comma and enclosed by square parenthesis.

Example:

[Run Memory ["-t","Mem: <usedratio>%"] 10, Run Swap [] 10]

to run the Memory monitor plugin with the specified template, and the swap monitor plugin, with default options, every second. And here's an example of a template for the commands above using an icon:

template="<icon=/home/jao/.xmobar/mem.xbm/><memory> <swap>"

This example will run "xclock" command when date is clicked:

template="<action=`xclock`>%date%</action>

The only internal available command is Com (see below Executing External Commands). All other commands are provided by plugins. xmobar comes with some plugins, providing a set of system monitors, a standard input reader, an Unix named pipe reader, a configurable date plugin, and much more: we list all available plugins below.

Other commands can be created as plugins with the Plugin infrastructure. See below.

5.6 System Monitor Plugins

This is the description of the system monitor plugins available in xmobar. Some of them are only installed when an optional build option is set: we mention that fact, when needed, in their description.

Each monitor has an alias to be used in the output template. Monitors have default aliases. The sections below describe every monitor in turn, but before we provide a list of the configuration options (or monitor arguments) they all share.

5.6.1 Icon patterns

Some monitors allow usage of strings that depend on some integer value from 0 to 8 by replacing all occurences of "%%" with it (i.e. "<icon=/path/to/icon_%%.xpm/>" will be interpreted as "<icon=/path/to/icon_3.xpm/>" when the value is 3, also "%" is interpreted as "%", "%%" as "3", "%%%" as "3%", "%%%%" as "33" and so on). Essentially it allows to replace vertical bars with custom icons. For example,

Run Brightness
  [ "-t", "<ipat>"
  , "--"
  , "--brightness-icon-pattern", "<icon=bright_%%.xpm/>"
  ] 30

Will display bright_0.xpm to bright_8.xpm depending on current brightness value.

5.6.2 Default Monitor Arguments

Monitors accept a common set of arguments, described in the first subsection below. In addition, some monitors accept additional options that are specific to them. When specifying the list of arguments in your configuration, the common options come first, followed by "--", followed by any monitor-specific options.

These are the options available for all monitors below:

Commands' arguments must be set as a list. E.g.:

Run Weather "EGPF" ["-t", "<station>: <tempC>C"] 36000

In this case xmobar will run the weather monitor, getting information for the weather station ID EGPF (Glasgow Airport, as a homage to GHC) every hour (36000 tenth of seconds), with a template that will output something like:

Glasgow Airport: 16.0C

5.6.3 Uptime Args RefreshRate

5.6.4 Weather StationID Args RefreshRate

5.6.5 Network Interface Args RefreshRate

5.6.6 DynNetwork Args RefreshRate

5.6.7 Wireless Interface Args RefreshRate

5.6.8 Memory Args RefreshRate

5.6.9 Swap Args RefreshRate

5.6.10 Cpu Args RefreshRate

5.6.11 MultiCpu Args RefreshRate

5.6.12 Battery Args RefreshRate

5.6.13 BatteryP Dirs Args RefreshRate

In the above example, the thresholds before the "--" separator affect only the <left> and <leftbar> fields, while those after the separator affect how <watts> is displayed. For this monitor, neither the generic nor the specific options have any effect on <timeleft>.

It is also possible to specify template variables in the -O and -o switches, as in the following example:

     Run BatteryP ["BAT0"]
                  ["-t", "<acstatus>"
                  , "-L", "10", "-H", "80"
                  , "-l", "red", "-h", "green"
                  , "--", "-O", "Charging", "-o", "Battery: <left>%"
                  ] 10

5.6.14 BatteryN Dirs Args RefreshRate Alias

Works like BatteryP, but lets you specify an alias for the monitor other than "battery". Useful in case you one separate monitors for more than one battery.

5.6.15 TopProc Args RefreshRate

5.6.16 TopMem Args RefreshRate

5.6.17 DiskU Disks Args RefreshRate

5.6.18 DiskIO Disks Args RefreshRate

5.6.19 ThermalZone Number Args RefreshRate

5.6.19.1 Thermal Zone Args RefreshRate

5.6.20 CpuFreq Args RefreshRate

5.6.21 CoreTemp Args RefreshRate

5.6.22 Volume Mixer Element Args RefreshRate

5.6.23 MPD Args RefreshRate

5.6.24 Mpris1 PlayerName Args RefreshRate

5.6.25 Mpris2 PlayerName Args RefreshRate

5.6.26 Mail Args Alias

5.6.27 MBox Mboxes Opts Alias

5.6.28 XPropertyLog PropName

5.6.29 UnsafeXPropertyLog PropName

5.6.30 NamedXPropertyLog PropName Alias

5.6.31 NamedXPropertyLog PropName Alias

5.6.32 Brightness Args RefreshRate

5.6.33 Kbd Opts

5.6.34 Locks

5.6.35 CatInt n fn

5.7 Executing External Commands

In order to execute an external command you can either write the command name in the template, in this case it will be executed without arguments, or you can configure it in the "commands" configuration option list with the Com template command:

Com ProgramName Args Alias RefreshRate

E.g.:

    Run Com "uname" ["-s","-r"] "" 0

can be used in the output template as %uname% (and xmobar will call uname only once), while

    Run Com "date" ["+\"%a %b %_d %H:%M\""] "mydate" 600

can be used in the output template as %mydate%

5.8 Other Plugins

StdinReader

UnsafeStdinReader

Date Format Alias RefreshRate

DateZone Format Locale Zone Alias RefreshRate

CommandReader "/path/to/program" Alias

PipeReader "default text:/path/to/pipe" Alias

MarqueePipeReader "default text:/path/to/pipe" (length, rate, sep) Alias

BufferedPipeReader Alias [(Timeout, Bool, "/path/to/pipe1"), ..]

Have your window manager send window titles to "/tmp/xmobar_window". They will always be shown and not reveal your xmobar. Sending some status information to "/tmp/xmobar_status" will reveal xmonad for 1.5 seconds and temporarily overwrite the window titles. - Take a look at samples/status.sh

XMonadLog

UnsafeXMonadLog

6 Plugins

6.1 Writing a Plugin

Writing a plugin for xmobar should be very simple. You need to create a data type with at least one constructor.

Next you must declare this data type an instance of the Exec class, by defining the 1 needed method (alternatively start or run) and 2 optional ones (alias and rate):

    start :: e -> (String -> IO ()) -> IO ()
    run   :: e -> IO String
    rate  :: e -> Int
    alias :: e -> String

start must receive a callback to be used to display the String produced by the plugin. This method can be used for plugins that need to perform asynchronous actions. See Plugins/PipeReader.hs for an example.

run can be used for simpler plugins. If you define only run the plugin will be run every second. To overwrite this default you just need to implement rate, which must return the number of tenth of seconds between every successive runs. See Plugins/HelloWorld.hs for an example of a plugin that runs just once, and Plugins/Date.hs for one that implements rate.

Notice that Date could be implemented as:

    instance Exec Date where
        alias (Date _ a _) = a
        start (Date f _ r) = date f r

    date :: String -> Int -> (String -> IO ()) -> IO ()
    date format r callback = do go
        where go = do
                t <- toCalendarTime =<< getClockTime
                callback $ formatCalendarTime defaultTimeLocale format t
                tenthSeconds r >> go

This implementation is equivalent to the one you can read in Plugins/Date.hs.

alias is the name to be used in the output template. Default alias will be the data type constructor.

Implementing a plugin requires importing the plugin API (the Exec class definition), that is exported by Plugins.hs. So you just need to import it in your module with:

    import Plugins

After that your type constructor can be used as an argument for the Runnable type constructor Run in the commands list of the configuration options.

This requires importing your plugin into Config.hs and adding your type to the type list in the type signature of Config.runnableTypes.

For a very basic example see samples/Plugins/HelloWorld.hs or the other plugins that are distributed with xmobar.

6.2 Installing/Removing a Plugin

Installing a plugin should require 3 steps. Here we are going to install the HelloWorld plugin that comes with xmobar, assuming that you copied it to src/Plugins:

  1. import the plugin module in Config.hs, by adding:

    import Plugins.HelloWorld
  2. add the plugin data type to the list of data types in the type signature of runnableTypes in Config.hs. For instance, for the HelloWorld plugin, change runnableTypes into:

    runnableTypes :: Command :*: Monitors :*: HelloWorld :*: ()
    runnableTypes = undefined
  3. Rebuild and reinstall xmobar. Now test it with:

    xmobar Plugins/helloworld.config

As you may see in the example configuration file, the plugin can be used by adding, in the commands list:

    Run HelloWorld

and, in the output template, the alias of the plugin:

    %helloWorld%

That's it.

To remove a plugin, just remove its type from the type signature of runnableTypes and remove the imported modules.

To remove the system monitor plugin:

  1. remove, from Config.hs, the line

    import Plugins.Monitors
  2. in Config.hs change

     runnableTypes :: Command :*: Monitors :*: ()
     runnableTypes = undefined

    to

     runnableTypes :: Command :*: ()
     runnableTypes = undefined
  3. rebuild xmobar.

7 Authors and credits

Andrea Rossato originally designed and implemented xmobar up to version 0.11.1. Since then, it is maintained and developed by jao, with the help of the greater xmobar and Haskell communities.

In particular, xmobar incorporates patches by Axel Angel, Ben Boeckel, Roman Cheplyaka, Patrick Chilton, Nathaniel Wesley Filardo, John Goerzen, Reto Hablützel, Juraj Hercek, Tomas Janousek, Spencer Janssen, Jochen Keil, Lennart Kolmodin, Krzysztof Kosciuszkiewicz, Dmitry Kurochkin, Todd Lunter, Robert J. Macomber, Dmitry Malikov, David McLean, Marcin Mikołajczyk, Tony Morris, Eric Mrak, Thiago Negri, Edward O'Callaghan, Svein Ove, Martin Perner, Jens Petersen, Alexander Polakov, Petr Rockai, Andrew Sackville-West, Alexander Shabalin, Peter Simons, Alexander Solovyov, John Soros, Travis Staton, Artem Tarasov, Sergei Trofimovich, Thomas Tuegel, Jan Vornberger, Anton Vorontsov, Daniel Wagner, Phil Xiaojun Hu and Norbert Zeh.

7.1 Thanks

Andrea Rossato:

Thanks to Robert Manea and Spencer Janssen for their help in understanding how X works. They gave me suggestions on how to solve many problems with xmobar.

Thanks to Claus Reinke for make me understand existential types (or at least for letting me think I grasp existential types...;-).

jao:

Thanks to Andrea for creating xmobar in the first place, and for giving me the chance to contribute.

8 Useful links

9 License

This software is released under a BSD-style license. See LICENSE for more details.

Copyright © 2010-2013 Jose Antonio Ortega Ruiz

Copyright © 2007-2010 Andrea Rossato