Difference between revisions of "Xmobar"

From ArchWiki
Jump to: navigation, search
(Gmail integration)
Line 1: Line 1:

Revision as of 16:31, 7 May 2011


xmobar is a lightweight bar written in haskell. It is one of the most popular bars to use together with Xmonad.
Even though it is written in haskell, you don't need to know haskell to configure it.


xmobar can be found in the [community] repository and the development version (xmobar-git) can be found in aur.


Xmobar can be configured both with command line options and a configuration file (~/.xmobarrc).
Any command line option will override the coresponding option set in the configuration file.

Using ~/.xmobarrc

Following is a short description of the options you can use in ~/.xmobarrc

The font to use. If you got XFT fonts enabled, prefix XFT fonts with xft:
The default colour to use for the font, takes both colour names and hex colours.
The colour of the bar, takes both colour names and hex colours.
The position of the bar. Keywords are: Top, TopW, Bottom, BottomW and Static.
  • Top/Bottom - The top/bottom of the screen.
  • TopW/BottomW - The top/bottom of the screen with a fixed with. They take 2 options:
    • Alignment: Left, Center or Right aligned.
    • Width: An iteger for the width of the bar in percent.
Example: Centered at the bottom of the screen, with a width of 75% of the screen.
position = BottomW C 75
  • Static - A fixed position on the screen, with a fixed with. Static takes 4 keyword arguments:
    • xpos: Horisontal position in pixels, starting at the upper left corner.
    • ypos: Vertical position in pixels, starting at the upper left corner.
    • width: The width of the bar in pixels.
    • height: The height of the bar in pixels.
Example: Top left of the screen, with a width of 1024 pixels and height of 15 pixels
position = Static { xpos = 0 , ypos = 0, width = 1024, height = 15 }
For setting the options of the programs to run (optional).
commands is a comma seperated list of commands, and their options. Example:
[Run Memory ["-t","Mem: <usedratio>%"] 10, Run Swap [] 10]
runs the Memory plugin, with the specified template, and the Swap plugin, with default args. And both with an update every second. (the update rate is in 1/10 seconds)
The character to be used for indicating commands in the output template (default '%').
A string of characters for aligning text in the output template. (default '}{') The text before the first char will be left aligned, the text between them will be centered, and the text to the right of the last char will be right aligned.
The output template is a string containing text and commands.
  •  %command% - An command to run. The output can contain a flag to set the colour of the text. You can chage the '%' to some other char with sepChar
  • <fc=colour></fc> - Sets the colour of a partion of text, takes both colour names and hex colours.

Example .xmobarrc file

Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
       , bgColor = "black"
       , fgColor = "grey"
       , position = Top
       , lowerOnStart = True
       , commands = [ Run Weather "EGPF" ["-t","<station>: <tempC>C","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000
                    , Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 10
                    , Run Network "eth1" ["-L","0","-H","32","--normal","green","--high","red"] 10
                    , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
                    , Run Memory ["-t","Mem: <usedratio>%"] 10
                    , Run Swap [] 10
                    , Run Com "uname" ["-s","-r"] "" 36000
                    , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
       , sepChar = "%"
       , alignSep = "}{"
       , template = "%cpu% | %memory% * %swap% | %eth0% - %eth1% }{ <fc=#ee9a00>%date%</fc>| %EGPF% | %uname%"

Gmail integration

Consider installing xmobar package with GMail plugin, then add this to your xmobarrc:

Config {    ...
             , commands = [ 
             , Run GMail "gmail.username" "GmailPassword" ["-t", "Mail: <count>"] 3000
      , template = "%cpu% ... %gmail.username% ... <fc=#ee9a00>%date%</fc>"

MPD intergration

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Xmobar#)

Since there also isn't an mpd plugin , you can use the same trick as the gmail plugin. You will need mpc for this , here is the simple script , save this script some where and run it like this :

Run Com "sh" ["~/bin/mpd.sh"] "mpd" 10 

In the template add this:


Conky-Cli integration

One might want to integrate conky-cli into xmobar because the plugins shipped with xmobar doesn't support displaying some types of information, such as the amount of space on a partition. Here is a bash script which pipes information from conky-cli into a text file which then cats the file.

# Filename: ~/.xmonad/conkyscript
conky -c ~/.conkyclirc -i1 -q > conkystat &
sleep 4
killall -q conky
cat conkystat
rm conkystat

Add this line to the commands section inside ~/.xmobarrc which makes the script run every 30 seconds.

                    , Run Com ".xmonad/conkyscript" ["&"] "conky" 300

Then add this to your .xinitrc before "exec xmonad".

.xmonad/conkyscript &
sleep 6 && xmobar &

Then add %conky% to your template section, and then it should work.


xmobar on hackage