You are not logged in.

#1 2012-10-31 17:39:17

rix
Member
Registered: 2012-07-25
Posts: 238

Dwm: how to change items order in the statusbar

Hi Archers,

I'd like to have tags and layouts symbols list on the right and other piped infos on the left in the Dwm statusbar.

I got this piece of code:

[...]

void
drawbar(Monitor *m) {
    int x;
    unsigned int i, occ = 0, urg = 0;
    unsigned long *col;
    Client *c;

    dc.x = -20;
    x = dc.x;

/*  if(m == selmon) {  // status is only drawn on selected monitor */
        dc.w = x + TEXTW(stext);
	dc.x = m->ww - dc.w;
	if(dc.x > x) {
		dc.x = x;
		dc.w = m->ww - x;
	}
	drawcoloredtext(stext);
/*}
	else
		dc.x = m->ww; */
	if((dc.w = dc.x - x) > bh) {
		dc.x = x;
		if(m->sel) {
			col = m == selmon ? dc.colors[1] : dc.colors[0];
			drawtext(m->sel->name, col, True);
			drawsquare(m->sel->isfixed, m->sel->isfloating, col);
		}
		else
			drawtext(NULL, dc.colors[0], False);
	}
	for(c = m->clients; c; c = c->next) {
		occ |= c->tags;
		if(c->isurgent)
			urg |= c->tags;
	}
	dc.x = 1210;
	dc.w = blw = TEXTW(m->ltsymbol);
	drawtext(m->ltsymbol, dc.colors[7], True);
	dc.x += dc.w;
	for(i = 0; i < LENGTH(tags); i++) {
		dc.w = TEXTW(tags[i]);
		col = dc.colors[ (m->tagset[m->seltags] & 1 << i ? 1:(urg & 1 << i ? 2:0))];
		drawtext(tags[i], col, True);
		drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i, occ & 1 << i, col);
		dc.x += dc.w;
	}
	XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
	XSync(dpy, False);
}

[...]

I just know basic C syntax and I don't really think adding pixels space in

[...] dc.x = 1210; [...]

is the right way to make tags and layouts symbols to display on the left of the screen.
With the above code longer texts disappear on the monitor edges, and clients titles at all instead.

About titles I think that positioning piped infos at -20(px) make them (which usually preceed piped infos) disappear on the left of the screen.
I think it's because

[...] drawcoloredtext(stext); [...]

stands both for titles and for the piped stuff.

Stuff order I'd like to have, should be the following:
<piped infos><space><space><clients titles><space><space><layouts><space><space><tags list>

Suggestions are lways really appreciate.
Thank so much.

Last edited by rix (2012-10-31 17:39:59)

Offline

#2 2012-11-25 21:32:11

rix
Member
Registered: 2012-07-25
Posts: 238

Re: Dwm: how to change items order in the statusbar

No one? Really?

Offline

#3 2012-11-25 21:57:58

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

Re: Dwm: how to change items order in the statusbar

Please stop bumping your threads: https://wiki.archlinux.org/index.php/Fo … te#Bumping

You should probably just use a WM with a more programmable interface.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2012-11-25 22:11:08

rix
Member
Registered: 2012-07-25
Posts: 238

Re: Dwm: how to change items order in the statusbar

C'mon man, I'm not looking for that, you know.
I don't understand why it is so difficult to just answer to the question since there are people who (declarating) could and I've respected forum rules and netiquette ("bump" a part...).

But I really don't want to start a flame or such. I will improve my C, this is the smartest thing to do.

Thanks.

Last edited by rix (2012-11-25 22:12:14)

Offline

#5 2012-11-25 22:52:06

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Dwm: how to change items order in the statusbar

Rix, please take the appropriate rebuke more gracefully and learn from it.

Because you show an interest in learning, I was motivated to take a brief look at this.  However, the tone you take (eg the demanding nature of it) tempers that motivation a good bit.  Realize that this is a community of volunteers - no one is oblidged to help you with anything.*

That all said, I did look at the drawbar code.  I tried it out on my dwm which has been so heavily modified - both for desired purposes as well as for other 'experiments' like this - it's hard to know how much this will translate.  I did see the problem you describe though.  I was able to solve it by adding the following three lines right before the drawing of the tags:

+       dc.w = 0;
+       for(i = 0; i < LENGTH(tags); i++) dc.w += TEXTW(tags[i]);
+       dc.x = m->ww - dc.w;
        for(i = 0; i < LENGTH(tags); i++) {
                dc.w = TEXTW(tags[i]);
        col = dc.colors[ (m->tagset[m->seltags] & 1 << i) ?
                4 : (urg & 1 << i ? 2:(occ & 1 << i ? 1:0)) ];
        drawtext(tags[i], col, True);
                dc.x += dc.w;
        }

note the pluses are just indicating changes - do not put them in your code.

*PS: also, if you disrespect contributing members of this community don't expect anyone to help you - I certainly will not offer further help if don't take this 'suggestion' to heart.

Last edited by Trilby (2012-11-25 22:55:11)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2012-11-26 09:56:03

rix
Member
Registered: 2012-07-25
Posts: 238

Re: Dwm: how to change items order in the statusbar

Trilby wrote:

[...] please take [...]

I already do it.

Trilby wrote:

[...] appropriate [...]

I don't think so. Points of view.

Trilby wrote:

[...] Because you show an interest in learning, [...]

You don't know how much, trust me.

Trilby wrote:

[...] Realize that this is a community of volunteers - no one is oblidged to help you with anything. [...]

Always know it - never say that.

Also I have to admit I'm not so sure to have completely understood your post because the language.

Trilby wrote:

[...] I did see the problem you describe though. [...]

And I thank you for the time you've spent for it, but also I'd like to know if just adding pixel space is a good way. Some text (piped too) goes over the status. I think my code isn't so good.

Trilby wrote:

[...] I was able to solve it [...]

Again thanks so much.
Do you mind also explain me how do you find such solution which I try and will let you know about? Thanks.

Trilby wrote:

[...] if you disrespect contributing members [...]

Do I've disrespected users?!

Offline

#7 2012-11-26 11:18:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Dwm: how to change items order in the statusbar

Good luck.  You're on your own.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2012-11-26 11:24:34

rix
Member
Registered: 2012-07-25
Posts: 238

Re: Dwm: how to change items order in the statusbar

I still don't understand what are you mean because of language. Sorry but english isn't my mother tongue.

Offline

Board footer

Powered by FluxBB