I'm using Fedora 18. I'm trying to create a custom status bar in dwm. Now what I'm thinking of is to check if the battery is under a certain level, the background of the battery region in the status bar will be red.

The problem is, when this condition is true, I get a different result.

What I expected this to be shown inside the status bar with a red background:

(red bg: Discharging, 50%) | 04:21:20 AM 29/06/2013

But I get :

ss of taskbar

Here's my startup script :

  3 # Created By Rafael Adel
  5 # This script is to start dwm with customizations needed
  8 while true;do
  9         datestr=`date +"%r %d/%m/%Y"`
 10         batterystr=`acpi | grep -oP "([a-zA-Z]*), ([0-9]*)%"`
 11         batterystate=`echo $batterystr | grep -oP "[a-zA-Z]*"`
 12         batterypercent=`echo $batterystr | grep -oP "[0-9]*"`
 15         if [ $batterypercent -le 90 ]
 16         then
 17                 finalstr="`echo -e "\033[41m${batterystr}\033[0m | $datestr"`"
 18         else
 19                 finalstr="$batterystr | $datestr"
 20         fi
 21                 xsetroot -name "$finalstr"
 22         sleep 1
 23 done &
 25 xbindkeys -f /etc/xbindkeysrc
 27 exec dwm

Any help will be appreciated. Thanks.

1 Answer 1


dwm does not have the capability to draw colored text in its status bar. If you want to fix this then you will need to modify drw.c:drw_text() in the dwm source code.

  • Do you mean that, i need to do what i did in the script above but in C in this method ? Or just add it in that file? Commented Jun 29, 2013 at 3:22
  • 1
    You will need to rewrite that function in order to parse and interpret the escape codes. Commented Jun 29, 2013 at 3:23
  • 1
    Or, you could use the statuscolors patch on the suckless wiki...
    – jasonwryan
    Commented Jun 29, 2013 at 5:26
  • @jasonwryan: That will give you a little bit of control over the color (and for this question, that little bit of control will be enough), but won't be enough to use even a partial set of escape codes. Commented Jun 29, 2013 at 5:32
  • 1
    It was never intended as a counter, but a complement. That's why it is a comment (and I upvoted your answer).
    – jasonwryan
    Commented Jun 29, 2013 at 7:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .