You are not logged in.

#1 2011-07-09 20:20:38

One
Member
From: .eu
Registered: 2011-07-05
Posts: 29

DWM perl, statuscolors and unwelcome whitespace

Hi there,

I have a perl script that I use to display some useful information through xsetroot.

while true
do
  xsetroot -name "$(perl /home/francis/bin/status.pl)"
  sleep 30
done &

I've applied the statuscolors patch and tried to add colour to my status bar, but I'm having problems with it. Using the \x0[1-9] color codes results in whitespace added to the output. Is there a way to eliminate this? Code and examples follow.

// perl code
if($cpu>=200){
  $col="\x05";
}
elsif($cpu>=100){
  $col="\x04";
}
else{
  $col="\x03";
}
$cpu='C'.$col.$cpu.'%';

// output
// output to console (correct but no color, of course)
C13%

// output to status bar (two spaces! and color)
C  13%

Also, for some reason I do not understand, I am only able to switch between the normal and the selected colors, even when I hard code \x04 or \x05.

#define NUMCOLORS 5
static const char colors[NUMCOLORS][ColLast][8] = {
  // border     foreground  background
  { "#383838",  "#d0d0d0",  "#262729" },  // normal
  { "#383838",  "#ff9500",  "#262729" },  // selected
  { "#383838",  "#00ff00",  "#262729" },  // fine
  { "#383838",  "#ffff00",  "#262729" },  // warning
  { "#383838",  "#ff0000",  "#262729" },  // error
};

Thanks

Last edited by One (2011-07-09 20:40:46)


First time Archer

Offline

#2 2011-07-09 21:12:03

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: DWM perl, statuscolors and unwelcome whitespace

This statuscolours patch fixes the whitespace issue http://lists.suckless.org/dev/1011/6445.html

dwm 5.9 comes out today, which means the patch will need slight tweaking...

# edit: you don't seem to have sufficient colours defined: numbering starts at 0


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2011-07-09 22:40:43

One
Member
From: .eu
Registered: 2011-07-05
Posts: 29

Re: DWM perl, statuscolors and unwelcome whitespace

Thank you, Jason, for the statuscolors patch. That issue is now solved.

However, I'm still stuck with 2 colours: normal and selected. Which numbering are you referring to? Why would I not have enough colours defined?

(I'll wait a while for dwm 5.9 - I'll need help with applying multiple patches...)


First time Archer

Offline

#4 2011-07-09 22:46:15

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: DWM perl, statuscolors and unwelcome whitespace

$col="\x05";

And, as far as I can count, you only have defined \x{0-4}


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2011-07-09 22:56:36

One
Member
From: .eu
Registered: 2011-07-05
Posts: 29

Re: DWM perl, statuscolors and unwelcome whitespace

AFAIK numbering starts at \x01 ( http://dwm.suckless.org/patches/statuscolors ), so it _should_ work.

But even if you were right, I should be able to produce 4 of my 5 colours. I can only get 2 now.


First time Archer

Offline

#6 2015-12-28 17:06:41

jgr
Member
Registered: 2015-12-21
Posts: 8

Re: DWM perl, statuscolors and unwelcome whitespace

This issue persists with the 6.1 statuscolors patch but as far as I can tell the code in drw_get_width() is designed to remove the whitespace. I'm having a lot of trouble fixing this myself ),:

Last edited by jgr (2016-01-12 17:20:32)

Offline

Board footer

Powered by FluxBB