Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 :

#!/bin/bash
  2 
  3 # Created By Rafael Adel
  4 
  5 # This script is to start dwm with customizations needed
  6 
  7 
  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]*"`
 13 
 14 
 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 &
 24 
 25 xbindkeys -f /etc/xbindkeysrc
 26 
 27 exec dwm

Any help will be appreciated. Thanks.

share|improve this question

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.

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
1  
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
1  
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
1  
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

 
discard

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.