Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
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? – Rafael Adel Jun 29 '13 at 3:22
You will need to rewrite that function in order to parse and interpret the escape codes. – Ignacio Vazquez-Abrams Jun 29 '13 at 3:23
Or, you could use the statuscolors patch on the suckless wiki... – jasonwryan Jun 29 '13 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. – Ignacio Vazquez-Abrams Jun 29 '13 at 5:32
It was never intended as a counter, but a complement. That's why it is a comment (and I upvoted your answer). – jasonwryan Jun 29 '13 at 7:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.