DWM: A pretty statusbar

dwm uses xsetroot to pipe text into its statusbar.
By default, the statusbar does not support colours and does not support xbm icons.
You could get this functionality by using third party apps such as dzen with conky.

To get this functionality natively within dwm 6.0:

  • Patch your dwm config with jasonwryan’s statuscolors-6.0
  • Take a look at jasonwryan’s dwm-status script the dzen website for some ideas of what text can be piped
  • Follow Lokaltag’s tutorial to draw symbols into your favourite bitmap font.
  • Look at dzen’s icon packs for some ideas of what can be drawn.

Here’s what my statusbar currently looks like (click for full length image):

For the lazy, here’s how to get the statusbar to look like the above:

  1. Save font as ~/.fonts/terminus2.bdf:
    https://github.com/w0ng/dwm/blob/master/terminus2.bdf
  2. Update font cache:
  3. $ xset +fp ~/.fonts
    # fc-cache -fv
  4. Save script as ~/.dwm-statusbar.bash:
    https://github.com/w0ng/bin/blob/master/dwm-statusbar
  5. Allow script to be executed:
    $ chmod +x ~/.dwm-statusbar.bash
  6. Apply jasonwryan’s statuscolors-6.0 patch
  7. Change font and statuscolors options in dwm/config.h:
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
    ...
    /* appearance */
    static const char font[]            = "-*-terminus2-medium-r-*-*-12-*-*-*-*-*-*-*";
    #define NUMCOLORS 6
    static const char colors[NUMCOLORS][ColLast][8] = {
      // border foreground background
      { "#073642", "#657b83", "#002b36" }, // 1 = normal (grey on black)
      { "#b58900", "#eee8d5", "#002b36" }, // 2 = selected (white on black)
      { "#dc322f", "#002b36", "#b58900" }, // 3 = urgent (black on yellow)
      { "#073642", "#839496", "#073642" }, // 4 = lightgrey on brightblack
      { "#073642", "#073642", "#002b36" }, // 5 = brightblack on black
      { "#073642", "#002b36", "#073642" }, // 6 = black on brightblack
    };
    ...
  8. Add statusbar script to ~/.xinitrc:
    ~/.dwm-statusbar.bash &
  9. Restart X

Edit: This appears to be a better solution (I haven’t tried it yet, though): https://bbs.archlinux.org/viewtopic.php?pid=1096029#p1096029

4 Comments

  1. eldamar says:

    I must be doing something wrong because i only get a empty statusbar after trying to use this icon solution, something about the output breaks my bar and everything after an icon or the icon character is not showing up for some reason, even if ii change to a font previosly working i still get nothing. i even tried to build from your PKGBUILD with every patch and the exact same config.h file, still didn’t work for me.

    • w0ng says:

      I’m guessing it’s because the statusbar script contains some files/variables that are only installed on my comp.

      You shouldn’t need any patches for this to work. All you need is to have terminus2 in ~/.fonts.

      To test whether the icon glyphs work, test if the statusbar displays fine after changing terminus to terminus2 in config.h.

      Next try to display some of the normal chars: e.g.
      $ xsetroot -name “abc”

      Then try to display some of the icon letters: e.g.
      $ xsetroot -name “ÜÜÝ”

      Then test each part of dwm-statusbar.bash (e.g. try getting print_datetime() to work and delete everything else).

      Note that a much easier alternative could be using conky to display system stats

  2. domac says:

    Hey,
    I just applied that patch and everything works well for me. Now I wanted to modify that statusbar to my needs. Can you tell me where to find the commands for the icons (at best to copy&paste) and how to add colors to them?
    Thanks!

    • w0ng says:

      To get colours piped to the statusbar, you need to use the statuscolours patch. To output the colours, you bash escape sequences, e.g. if I wanted to output something in black in black on yellow (3rd colour definition in the posted config.h), you would pipe it with echo -e “\x03foobar”

      To find the unicode or escape chars for the icon glyphs, use something like xorg-xfd or gbdfed or fontforge

Leave a Reply