You are not logged in.

#1351 2014-04-08 23:17:40

w0ng
Member
From: Australia
Registered: 2009-06-04
Posts: 88
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

sediment wrote:

Has anyone by any chance got a patch for this lying around already?

The nature of dwm is that official patches are applied to the stock dwm.c. When applying >1 patch, you should expect to manually apply the diffs. Also, you should probably create a support thread for this.

Offline

#1352 2014-04-12 11:09:14

chickenPie4tea
Member
Registered: 2012-08-21
Posts: 309

Re: DWM Hackers Unite! Share (or request) dwm patches.

mkaito wrote:
ivoarch wrote:

Prefix-key.diff - Ratpoison/StumpWM style (using prefix key).
- Autor: matt mooney
- Modified: ivo

Any chance you expand a little about what this does and how to use it?

I was interested too but the link is broken sad


You can like linux without becoming a fanatic!

Offline

#1353 2014-04-12 11:38:48

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Otherwise you could try a Google search... there are numerous links popping up that have an older version of  prefix key patch.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#1354 2014-04-17 14:08:25

defer
Member
From: Finland
Registered: 2013-06-25
Posts: 46
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

pks wrote:
markoer wrote:

@pks

if there is more than one client in stack you can see gap which increases every time a new client is spawned in stack

Yeah, I've spotted that issue as well, it's some kind of rounding error. I'll think of a fix.

Edit: I've updated the patch, it works for me now without the increasing-gaps-issue.

diff --git a/config.def.h b/config.def.h
index 875885b..3dbd05f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -65,6 +65,8 @@ static Key keys[] = {
 	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
 	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
 	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
+	{ MODKEY|ShiftMask,             XK_h,      setcfact,       {.f = +0.05} },
+	{ MODKEY|ShiftMask,             XK_l,      setcfact,       {.f = -0.05} },
 	{ MODKEY,                       XK_Return, zoom,           {0} },
 	{ MODKEY,                       XK_Tab,    view,           {0} },
 	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
diff --git a/dwm.c b/dwm.c
index 1bbb4b3..f16ab61 100644
--- a/dwm.c
+++ b/dwm.c
@@ -86,6 +86,7 @@ typedef struct Client Client;
 struct Client {
 	char name[256];
 	float mina, maxa;
+	float cfact;
 	int x, y, w, h;
 	int oldx, oldy, oldw, oldh;
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
@@ -200,6 +201,7 @@ static void setclientstate(Client *c, long state);
 static void setfocus(Client *c);
 static void setfullscreen(Client *c, Bool fullscreen);
 static void setlayout(const Arg *arg);
+static void setcfact(const Arg *arg);
 static void setmfact(const Arg *arg);
 static void setup(void);
 static void showhide(Client *c);
@@ -1027,6 +1029,7 @@ manage(Window w, XWindowAttributes *wa) {
 	c->w = c->oldw = wa->width;
 	c->h = c->oldh = wa->height;
 	c->oldbw = wa->border_width;
+	c->cfact = 1.0;
 
 	if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
 		c->x = c->mon->mx + c->mon->mw - WIDTH(c);
@@ -1473,6 +1476,21 @@ setlayout(const Arg *arg) {
 		drawbar(selmon);
 }
 
+void setcfact(const Arg *arg) {
+	float f;
+	Client *c;
+
+	c = selmon->sel;
+
+	if(!arg || !c || !selmon->lt[selmon->sellt]->arrange)
+		return;
+	f = arg->f + c->cfact;
+	if(f < 0.25 || f > 4.0)
+		return;
+	c->cfact = f;
+	arrange(selmon);
+}
+
 /* arg > 1.0 will set mfact absolutly */
 void
 setmfact(const Arg *arg) {
@@ -1602,9 +1620,15 @@ tagmon(const Arg *arg) {
 void
 tile(Monitor *m) {
 	unsigned int i, n, h, mw, my, ty;
+	float mfacts = 0, sfacts = 0;
 	Client *c;
 
-	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
+		if(n < m->nmaster)
+			mfacts += c->cfact;
+		else
+			sfacts += c->cfact;
+	}
 	if(n == 0)
 		return;
 
@@ -1614,14 +1638,16 @@ tile(Monitor *m) {
 		mw = m->ww;
 	for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
 		if(i < m->nmaster) {
-			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
+			h = (m->wh - my) * (c->cfact / mfacts) + 0.5;
 			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
 			my += HEIGHT(c);
+			mfacts -= c->cfact;
 		}
 		else {
-			h = (m->wh - ty) / (n - i);
+			h = (m->wh - ty) * (c->cfact / sfacts) + 0.5;
 			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
 			ty += HEIGHT(c);
+			sfacts -= c->cfact;
 		}
 }
 

This patch is awesome! Thanks. I was just what i was looking for.

Offline

#1355 2014-04-18 19:26:46

drobati
Member
From: Atlanta
Registered: 2014-04-18
Posts: 2
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Where is a good place to get support for DWM?

When I run 'startx' and have 'exec dwm' in my .xinitrc, the screen goes pitch black and no key bindings worked. I installed i3 and it loaded fine, so I'm not sure the issue is with xorg. I've 'sudo make uninstall', and then downloaded a vanilla dwm-6.0.tar.gz to reinstall. That still doesn't work. sad

I run dwm on another virtual machine and it works great! I love all the patches and configs!

Offline

#1356 2014-04-18 19:59:19

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

Re: DWM Hackers Unite! Share (or request) dwm patches.

Not here. Set up dwm to log any errors to a file and then open a support thread with the debugging information.

while true; do
    dwm 2> ~/dwm.log
done

Your Xorg log would also be relevant.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#1357 2014-04-18 21:26:00

drobati
Member
From: Atlanta
Registered: 2014-04-18
Posts: 2
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Thanks Jason. I did use that dwm-start, but it didn't produce anything meaningful. I'll do as suggested. smile

Offline

#1358 2014-05-05 10:41:13

spupy
Member
Registered: 2009-08-12
Posts: 218

Re: DWM Hackers Unite! Share (or request) dwm patches.

Is there a patch for chorded key combinations like in Emacs? I know about the command mode patch (vim-like command+insert mode), but it's only a single mode, while I need multiple. 
I come from i3, where modes are built-in. For example, pressing Mod4+U enables a mode where all 'U'tils are single key press. "Mod4+U,H" is htop, "Mod4+U,A" is alsamixer, etc. I have another mode (Mod4+C) for internet-related apps, then couple of more modes for other app categories and folders. 
I just don't have enough keyboard keys for all the things I need, so I resorted to this. 

Alternatively, I *think* I could use xbindkeys for a wm-agnostic key combos, but I haven't had success yet (need to RTFM more).


There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.

Offline

#1359 2014-05-05 12:00:09

pks
Member
From: Germany
Registered: 2012-07-20
Posts: 110

Re: DWM Hackers Unite! Share (or request) dwm patches.

spupy wrote:

Is there a patch for chorded key combinations like in Emacs? I know about the command mode patch (vim-like command+insert mode), but it's only a single mode, while I need multiple. 
I come from i3, where modes are built-in. For example, pressing Mod4+U enables a mode where all 'U'tils are single key press. "Mod4+U,H" is htop, "Mod4+U,A" is alsamixer, etc. I have another mode (Mod4+C) for internet-related apps, then couple of more modes for other app categories and folders. 
I just don't have enough keyboard keys for all the things I need, so I resorted to this. 

Alternatively, I *think* I could use xbindkeys for a wm-agnostic key combos, but I haven't had success yet (need to RTFM more).

You should take a look at sxhkd [1] as an alternative to xbindkeys. It supports chorded key combinations, as well.

[1]: https://aur.archlinux.org/packages/sxhkd/

Offline

#1360 2014-05-05 12:43:17

spupy
Member
Registered: 2009-08-12
Posts: 218

Re: DWM Hackers Unite! Share (or request) dwm patches.

pks wrote:
spupy wrote:

Is there a patch for chorded key combinations like in Emacs? I know about the command mode patch (vim-like command+insert mode), but it's only a single mode, while I need multiple. 
I come from i3, where modes are built-in. For example, pressing Mod4+U enables a mode where all 'U'tils are single key press. "Mod4+U,H" is htop, "Mod4+U,A" is alsamixer, etc. I have another mode (Mod4+C) for internet-related apps, then couple of more modes for other app categories and folders. 
I just don't have enough keyboard keys for all the things I need, so I resorted to this. 

Alternatively, I *think* I could use xbindkeys for a wm-agnostic key combos, but I haven't had success yet (need to RTFM more).

You should take a look at sxhkd [1] as an alternative to xbindkeys. It supports chorded key combinations, as well.

[1]: https://aur.archlinux.org/packages/sxhkd/

This looks like exactly what I'm looking for! Thank you very much!


There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.

Offline

#1361 2014-05-11 21:56:05

spychalski
Member
Registered: 2012-03-11
Posts: 7

Re: DWM Hackers Unite! Share (or request) dwm patches.

Has anyone had any success porting the ansistatuscolors patch (or any equivalent) to 6.1? I'm not familiar enough with the code to make those changes myself. The changes that added drw.[hc] broke most of the graphical patches, such as Xft, pango, statuscolors, etc.

I would be using 6.0 but I simply cannot live without the multi-monitor patches for 6.1 ATM. sad

Any help is appreciated.

//edits: grammar, wrong patch name!

Last edited by spychalski (2014-05-11 21:58:41)

Offline

#1362 2014-05-12 07:38:08

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

I dont know about ansistatuscolors, but my repo does have Pango implemented in 6.1. Feep free to check it out.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#1363 2014-05-16 21:02:30

totolotto
Member
From: Hungary
Registered: 2012-11-13
Posts: 114

Re: DWM Hackers Unite! Share (or request) dwm patches.

I have hand-patched runorraise in dwm-6.0. The build is successful and dwm seems to be working fine, but I have a warning message during build:

dwm.c: In function ‘runorraise’:
dwm.c:1452:25: warning: initialization discards ‘const’ qualifier from pointer target type
      const char **app = arg->v;
                         ^

and the function:

void
runorraise(const Arg *arg) {                                                      
     const char **app = arg->v;
     Arg a = { .ui = ~0 };                                                   
     Monitor *mon;                                               
     Client *c;                  
     XClassHint hint = { NULL, NULL };                                           
     for (mon = mons; mon; mon = mon->next) {                               
       for (c = mon->clients; c; c = c->next) {                                
         XGetClassHint(dpy, c->win, &hint);                                
         if (hint.res_class && strcmp(app[2], hint.res_class) == 0) {                  
           a.ui = c->tags;                  
           view(&a);                    
           focus(c);                               
           return;                 
         }                                  
       }              
     }                                    
     spawn(arg);                                    
}

My C knowledge is very limited. Can anyone tell how to fix it?

Offline

#1364 2014-05-16 22:29:44

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,201

Re: DWM Hackers Unite! Share (or request) dwm patches.

Omit the 'const' keyword.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#1365 2014-05-16 22:42:50

ivoarch
Member
Registered: 2011-03-31
Posts: 436

Re: DWM Hackers Unite! Share (or request) dwm patches.


I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#1366 2014-05-17 05:07:39

totolotto
Member
From: Hungary
Registered: 2012-11-13
Posts: 114

Re: DWM Hackers Unite! Share (or request) dwm patches.

@ ewaller
I have the same warning without const keyword.

@ivoarch
I tried but this patch does not work (at least for 6.0) - it does not find the client so that just gets opened again and again.

Offline

#1367 2014-05-17 07:10:07

jpgg
Member
Registered: 2014-01-15
Posts: 43

Re: DWM Hackers Unite! Share (or request) dwm patches.

totolotto wrote:

@ ewaller
I have the same warning without const keyword.

Actually, you had to add a const. The correct line would be :

const char * const * app = arg->v;

Offline

#1368 2014-05-17 08:27:38

ivoarch
Member
Registered: 2011-03-31
Posts: 436

Re: DWM Hackers Unite! Share (or request) dwm patches.

I've tested it and it works prefect on dwm 6.0
Something is wrong in your config.h?

// example for run or raise Firefox
static const char *browser[] = { "firefox", NULL, NULL, NULL, "Firefox" }
{ Modkey,                       XK_f,      runorraise,     {.v = browser } },

Last edited by ivoarch (2014-05-17 08:28:09)


I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#1369 2014-05-17 15:36:16

totolotto
Member
From: Hungary
Registered: 2012-11-13
Posts: 114

Re: DWM Hackers Unite! Share (or request) dwm patches.

@jpgg
Perfect, it builds now without warning!

@ivoarch
You are also right as in my config.h I have less arguments

static const char *term[] = { "urxvtc", NULL, "URxvt" };

but to be honest I have not tried it since jpgg's solution is simpler in this case. Thanks, both of you!

Offline

#1370 2014-06-21 03:07:13

mmix
Member
Registered: 2014-01-11
Posts: 33

Re: DWM Hackers Unite! Share (or request) dwm patches.

ivoarch wrote:

Try using wmname is mentioned in dwm's man page!

wmname LG3D

it works for android studio/jdk6. thx.

Offline

#1371 2014-07-23 23:22:23

algui91
Member
Registered: 2014-07-23
Posts: 1

Re: DWM Hackers Unite! Share (or request) dwm patches.

spychalski wrote:

Has anyone had any success porting the ansistatuscolors patch (or any equivalent) to 6.1? I'm not familiar enough with the code to make those changes myself. The changes that added drw.[hc] broke most of the graphical patches, such as Xft, pango, statuscolors, etc.

I would be using 6.0 but I simply cannot live without the multi-monitor patches for 6.1 ATM. sad

Any help is appreciated.

//edits: grammar, wrong patch name!


Hi, I just made a patch for something similar to statuscolor. I did the best I could. I am sure many people in this forum can do it better. It has some limitations, only works with dwmstatus and by default it has 4 colors. You can see the code in my repo (https://github.com/algui91/myDWM/blob/m … color.diff).

My current config is in the `myconfig` branch (https://github.com/algui91/myDWM/tree/myconfig).

Also, If you do not have any code for dwmstatus, here is mine (https://github.com/algui91/myDWMstatus), it has some hard coded things, like the net (eth0, wlan0 etc), but that is easily editable.

Here is an screenshot link here (http://i.imgbox.com/dUIp8myK.png):

Simple Status Color for dwm 6.1

Hope it helps!, And everyone feel free to improve my patch.

Best regards.

Last edited by algui91 (2014-07-24 16:11:19)

Offline

#1372 2014-08-18 22:27:45

holomorph
Member
Registered: 2012-10-19
Posts: 6

Re: DWM Hackers Unite! Share (or request) dwm patches.

Took another crack at statuscolours, got something satisfactory, I guess.

diff --git a/config.def.h b/config.def.h
index 875885b..c80255b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -2,12 +2,12 @@
 
 /* appearance */
 static const char font[]            = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
-static const char normbordercolor[] = "#444444";
-static const char normbgcolor[]     = "#222222";
-static const char normfgcolor[]     = "#bbbbbb";
-static const char selbordercolor[]  = "#005577";
-static const char selbgcolor[]      = "#005577";
-static const char selfgcolor[]      = "#eeeeee";
+static const char schemes[NUMSCHEMES][ColLast][8] = {
+	/* border background foreground */
+	{ "#444444", "#222222", "#bbbbbb" }, /* 1 = normal */
+	{ "#005577", "#005577", "#eeeeee" }, /* 2 = selected */
+	{ "#aa4444", "#222222", "#aa4444" }, /* 3 = urgent */
+};
 static const unsigned int borderpx  = 1;        /* border pixel of windows */
 static const unsigned int snap      = 32;       /* snap pixel */
 static const Bool showbar           = True;     /* False means no bar */
@@ -51,7 +51,7 @@ static const Layout layouts[] = {
 
 /* commands */
 static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
-static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
+static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", font, "-nb", schemes[0][ColBG], "-nf", schemes[0][ColFG], "-sb", schemes[1][ColBG], "-sf", schemes[1][ColFG], NULL };
 static const char *termcmd[]  = { "st", NULL };
 
 static Key keys[] = {
diff --git a/drw.c b/drw.c
index b130405..fcb6003 100644
--- a/drw.c
+++ b/drw.c
@@ -126,12 +126,12 @@ drw_setscheme(Drw *drw, ClrScheme *scheme) {
 }
 
 void
-drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert) {
+drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty) {
 	int dx;
 
 	if(!drw || !drw->font || !drw->scheme)
 		return;
-	XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->bg->rgb : drw->scheme->fg->rgb);
+	XSetForeground(drw->dpy, drw->gc, drw->scheme->fg->rgb);
 	dx = (drw->font->ascent + drw->font->descent + 2) / 4;
 	if(filled)
 		XFillRectangle(drw->dpy, drw->drawable, drw->gc, x+1, y+1, dx+1, dx+1);
@@ -140,22 +140,22 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
 }
 
 void
-drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert) {
+drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int pad) {
 	char buf[256];
 	int i, tx, ty, th, len, olen;
 	Extnts tex;
 
 	if(!drw || !drw->scheme)
 		return;
-	XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->fg->rgb : drw->scheme->bg->rgb);
+	XSetForeground(drw->dpy, drw->gc, drw->scheme->bg->rgb);
 	XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
 	if(!text || !drw->font)
 		return;
 	olen = strlen(text);
 	drw_font_getexts(drw->font, text, olen, &tex);
-	th = drw->font->ascent + drw->font->descent;
-	ty = y + (h / 2) - (th / 2) + drw->font->ascent;
-	tx = x + (h / 2);
+	th = pad ? (drw->font->ascent + drw->font->descent) : 0;
+	ty = y + ((h + drw->font->ascent - drw->font->descent) / 2);
+	tx = x + (th / 2);
 	/* shorten text if necessary */
 	for(len = MIN(olen, sizeof buf); len && (tex.w > w - tex.h || w < tex.h); len--)
 		drw_font_getexts(drw->font, text, len, &tex);
@@ -164,7 +164,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
 	memcpy(buf, text, len);
 	if(len < olen)
 		for(i = len; i && i > len - 3; buf[--i] = '.');
-	XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->bg->rgb : drw->scheme->fg->rgb);
+	XSetForeground(drw->dpy, drw->gc, drw->scheme->fg->rgb);
 	if(drw->font->set)
 		XmbDrawString(drw->dpy, drw->drawable, drw->font->set, drw->gc, tx, ty, buf, len);
 	else
@@ -182,18 +182,30 @@ drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) {
 
 void
 drw_font_getexts(Fnt *font, const char *text, unsigned int len, Extnts *tex) {
+	/* remove non-printing color codes before calculating width */
+	char *ptr = (char *) text;
+	unsigned int i, ibuf;
+	char buf[len + 1];
 	XRectangle r;
 
+	for(i = 0, ibuf = 0; *ptr && i < len; i++, ptr++) {
+		if(!(*ptr <= NUMSCHEMES && *ptr > 0)) {
+			buf[ibuf] = *ptr;
+			ibuf++;
+		}
+	}
+	buf[ibuf] = 0;
+
 	if(!font || !text)
 		return;
 	if(font->set) {
-		XmbTextExtents(font->set, text, len, NULL, &r);
+		XmbTextExtents(font->set, buf, ibuf, NULL, &r);
 		tex->w = r.width;
 		tex->h = r.height;
 	}
 	else {
 		tex->h = font->ascent + font->descent;
-		tex->w = XTextWidth(font->xfont, text, len);
+		tex->w = XTextWidth(font->xfont, buf, ibuf);
 	}
 }
 
diff --git a/drw.h b/drw.h
index a5f34e0..dac0184 100644
--- a/drw.h
+++ b/drw.h
@@ -1,5 +1,7 @@
 /* See LICENSE file for copyright and license details. */
 
+#define NUMSCHEMES              3
+
 typedef struct {
 	unsigned long rgb;
 } Clr;
@@ -62,8 +64,8 @@ void drw_setfont(Drw *drw, Fnt *font);
 void drw_setscheme(Drw *drw, ClrScheme *scheme);
 
 /* Drawing functions */
-void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert);
-void drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert);
+void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty);
+void drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int pad);
 
 /* Map functions */
 void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
diff --git a/dwm.c b/dwm.c
index f896170..9ae2fb0 100644
--- a/dwm.c
+++ b/dwm.c
@@ -59,6 +59,7 @@
 /* enums */
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
 enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */
+enum { ColBorder, ColBG, ColFG, ColLast }; /* scheme elements */
 enum { NetSupported, NetWMName, NetWMState,
        NetWMFullscreen, NetActiveWindow, NetWMWindowType,
        NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -163,6 +164,7 @@ static void detachstack(Client *c);
 static Monitor *dirtomon(int dir);
 static void drawbar(Monitor *m);
 static void drawbars(void);
+static void drawcoloredtext(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text);
 static void enternotify(XEvent *e);
 static void expose(XEvent *e);
 static void focus(Client *c);
@@ -260,7 +262,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
 static Atom wmatom[WMLast], netatom[NetLast];
 static Bool running = True;
 static Cur *cursor[CurLast];
-static ClrScheme scheme[SchemeLast];
+static ClrScheme scheme[NUMSCHEMES];
 static Display *dpy;
 static Drw *drw;
 static Fnt *fnt;
@@ -691,6 +693,32 @@ dirtomon(int dir) {
 }
 
 void
+drawcoloredtext(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text) {
+	char *buf = (char *)text, *ptr = buf, c = 1;
+	ClrScheme col = scheme[SchemeNorm];
+	int i, ox = x;
+
+	while(*ptr) {
+		for(i = 0; *ptr < 0 || *ptr > NUMSCHEMES; i++, ptr++);
+		if(!*ptr) break;
+		c = *ptr;
+		*ptr = 0;
+		if(i) {
+			w = selmon->ww - x;
+			drw_setscheme(drw, &col);
+			drw_text(drw, x, 0, w, bh, buf, 1);
+			x += drw_font_getexts_width(drw->font, buf, i);
+		}
+		*ptr = c;
+		col = scheme[c - 1];
+		buf = ++ptr;
+	}
+	drw_setscheme(drw, &col);
+	drw_text(drw, x, 0, w, bh, buf, 1);
+	x = ox;
+}
+
+void
 drawbar(Monitor *m) {
 	int x, xx, w;
 	unsigned int i, occ = 0, urg = 0;
@@ -704,15 +732,15 @@ drawbar(Monitor *m) {
 	x = 0;
 	for(i = 0; i < LENGTH(tags); i++) {
 		w = TEXTW(tags[i]);
-		drw_setscheme(drw, m->tagset[m->seltags] & 1 << i ? &scheme[SchemeSel] : &scheme[SchemeNorm]);
-		drw_text(drw, x, 0, w, bh, tags[i], urg & 1 << i);
+		drw_setscheme(drw, &scheme[(m->tagset[m->seltags] & 1 << i) ? 1 : (urg & 1 << i ? 2:0)]);
+		drw_text(drw, x, 0, w, bh, tags[i], 1);
 		drw_rect(drw, x, 0, w, bh, m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
-		           occ & 1 << i, urg & 1 << i);
+		           occ & 1 << i);
 		x += w;
 	}
 	w = blw = TEXTW(m->ltsymbol);
 	drw_setscheme(drw, &scheme[SchemeNorm]);
-	drw_text(drw, x, 0, w, bh, m->ltsymbol, 0);
+	drw_text(drw, x, 0, w, bh, m->ltsymbol, 1);
 	x += w;
 	xx = x;
 	if(m == selmon) { /* status is only drawn on selected monitor */
@@ -722,16 +750,16 @@ drawbar(Monitor *m) {
 			x = xx;
 			w = m->ww - xx;
 		}
-		drw_text(drw, x, 0, w, bh, stext, 0);
+		drawcoloredtext(drw, x, 0, w, bh, stext);
 	}
 	else
 		x = m->ww;
 	if((w = x - xx) > bh) {
 		x = xx;
 		if(m->sel) {
-			drw_setscheme(drw, m == selmon ? &scheme[SchemeSel] : &scheme[SchemeNorm]);
-			drw_text(drw, x, 0, w, bh, m->sel->name, 0);
-			drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, 0);
+			drw_setscheme(drw, &scheme[m == selmon ? SchemeSel : SchemeNorm]);
+			drw_text(drw, x, 0, w, bh, m->sel->name, 1);
+			drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating);
 		}
 		else {
 			drw_setscheme(drw, &scheme[SchemeNorm]);
@@ -1531,12 +1559,11 @@ setup(void) {
 	cursor[CurResize] = drw_cur_create(drw, XC_sizing);
 	cursor[CurMove] = drw_cur_create(drw, XC_fleur);
 	/* init appearance */
-	scheme[SchemeNorm].border = drw_clr_create(drw, normbordercolor);
-	scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor);
-	scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor);
-	scheme[SchemeSel].border = drw_clr_create(drw, selbordercolor);
-	scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor);
-	scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor);
+	for(int i = 0; i < NUMSCHEMES; i++) {
+		scheme[i].border = drw_clr_create(drw, schemes[i][ColBorder]);
+		scheme[i].bg = drw_clr_create(drw, schemes[i][ColBG]);
+		scheme[i].fg = drw_clr_create(drw, schemes[i][ColFG]);
+	}
 	/* init bars */
 	updatebars();
 	updatestatus();
@@ -1957,8 +1984,11 @@ updatewmhints(Client *c) {
 			wmh->flags &= ~XUrgencyHint;
 			XSetWMHints(dpy, c->win, wmh);
 		}
-		else
+		else {
 			c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
+			if(c->isurgent)
+				XSetWindowBorder(dpy, c->win, scheme[SchemeLast].border->rgb);
+		}
 		if(wmh->flags & InputHint)
 			c->neverfocus = !wmh->input;
 		else

Spacing issues still exist.  As the patch stands this still happens:

holomorph wrote:

For instance, in

xsetroot -name "$(printf "a\x01b\x02c")"

both `a` and `b` would get buried.

On the other hand, changing whether pad is 0 or 1 in calls to drw_text will juggle between fixing the above and introducing other spacing bugs.

Offline

#1373 2014-08-20 18:49:30

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: DWM Hackers Unite! Share (or request) dwm patches.

So I've been sloppily trying to get a couple things working, and my near-nonexistent C skills and knowledge have left me stumped. The first thing is this centerclock patch; I'd like the clock to be displayed on the far right of the statusbar---next to the status text---and leave the maximum width of the section at the number of characters in the clock text. I haven't quite figured out how to draw the clock text in its own section rather than replacing the status or window title text.

The second thing is to just change the window border color from dc.sel[ColBorder] to dc.norm[ColBG] in the monocle layout, to match the statusbar. This removes the visual distraction of the border, but leaves a few pixels of padding around the screen edge and below the statusbar text. If I've only got one window visible I'm in monocle mode anyway, so something like the better-borders and noborders patches seems like overkill. I've sort of figured out how this might work, but nothing reliable.  Like I said, I don't really grok C.

I'm using dwm 6.0. I've been fumbling around with this for two days, so if anyone's got some pointers, or is willing to make those modifications, I'd be grateful.

Offline

#1374 2014-08-30 18:25:52

Nikiz
Member
From: Finland
Registered: 2014-08-24
Posts: 6
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

I don't know if this is here already here, but, I will still post it.
In the screenshots the font is set to Comic Sans. big_smile

Use different font for status text and for the layout text:
1Yw09hn.png

diff -u a/config.def.h b/config.def.h
--- a/config.def.h	2014-08-27 22:37:22.405306000 +0300
+++ b/config.def.h	2014-08-30 21:19:24.349576945 +0300
@@ -2,6 +2,7 @@
 
 /* appearance */
 static const char font[]            = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
+static const char font2[]           = "-*-tamsynmod-medium-r-*-*-16-*-*-*-*-*-*-*";
 static const char normbordercolor[] = "#444444";
 static const char normbgcolor[]     = "#222222";
 static const char normfgcolor[]     = "#bbbbbb";
diff -u a/dwm.c b/dwm.c
--- a/dwm.c	2014-08-27 22:37:22.405306000 +0300
+++ b/dwm.c	2014-08-30 21:04:05.039559679 +0300
@@ -263,7 +263,7 @@
 static ClrScheme scheme[SchemeLast];
 static Display *dpy;
 static Drw *drw;
-static Fnt *fnt;
+static Fnt *fnt, *fnt2;
 static Monitor *mons, *selmon;
 static Window root;
 
@@ -475,6 +475,7 @@
 	drw_cur_free(drw, cursor[CurResize]);
 	drw_cur_free(drw, cursor[CurMove]);
 	drw_font_free(dpy, fnt);
+	drw_font_free(dpy, fnt2);
 	drw_clr_free(scheme[SchemeNorm].border);
 	drw_clr_free(scheme[SchemeNorm].bg);
 	drw_clr_free(scheme[SchemeNorm].fg);
@@ -710,6 +711,7 @@
 		           occ & 1 << i, urg & 1 << i);
 		x += w;
 	}
+	drw_setfont(drw, fnt2);
 	w = blw = TEXTW(m->ltsymbol);
 	drw_setscheme(drw, &scheme[SchemeNorm]);
 	drw_text(drw, x, 0, w, bh, m->ltsymbol, 0);
@@ -739,6 +741,7 @@
 		}
 	}
 	drw_map(drw, m->barwin, 0, 0, m->ww, bh);
+	drw_setfont(drw, fnt);
 }
 
 void
@@ -1507,6 +1510,7 @@
 	screen = DefaultScreen(dpy);
 	root = RootWindow(dpy, screen);
 	fnt = drw_font_create(dpy, font);
+	fnt2 = drw_font_create(dpy, font2);
 	sw = DisplayWidth(dpy, screen);
 	sh = DisplayHeight(dpy, screen);
 	bh = fnt->h + 2;

Or just for the status text:
I25iCor.png

diff -u a/config.def.h b/config.def.h
--- a/config.def.h	2014-08-27 22:37:22.405306000 +0300
+++ b/config.def.h	2014-08-30 21:19:24.349576945 +0300
@@ -2,6 +2,7 @@
 
 /* appearance */
 static const char font[]            = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
+static const char font2[]           = "-*-tamsynmod-medium-r-*-*-16-*-*-*-*-*-*-*";
 static const char normbordercolor[] = "#444444";
 static const char normbgcolor[]     = "#222222";
 static const char normfgcolor[]     = "#bbbbbb";
diff -u a/dwm.c b/dwm.c
--- a/dwm.c	2014-08-27 22:37:22.405306000 +0300
+++ b/dwm.c	2014-08-30 21:23:19.949581371 +0300
@@ -263,7 +263,7 @@
 static ClrScheme scheme[SchemeLast];
 static Display *dpy;
 static Drw *drw;
-static Fnt *fnt;
+static Fnt *fnt, *fnt2;
 static Monitor *mons, *selmon;
 static Window root;
 
@@ -475,6 +475,7 @@
 	drw_cur_free(drw, cursor[CurResize]);
 	drw_cur_free(drw, cursor[CurMove]);
 	drw_font_free(dpy, fnt);
+	drw_font_free(dpy, fnt2);
 	drw_clr_free(scheme[SchemeNorm].border);
 	drw_clr_free(scheme[SchemeNorm].bg);
 	drw_clr_free(scheme[SchemeNorm].fg);
@@ -713,6 +714,7 @@
 	w = blw = TEXTW(m->ltsymbol);
 	drw_setscheme(drw, &scheme[SchemeNorm]);
 	drw_text(drw, x, 0, w, bh, m->ltsymbol, 0);
+	drw_setfont(drw, fnt2);
 	x += w;
 	xx = x;
 	if(m == selmon) { /* status is only drawn on selected monitor */
@@ -739,6 +741,7 @@
 		}
 	}
 	drw_map(drw, m->barwin, 0, 0, m->ww, bh);
+	drw_setfont(drw, fnt);
 }
 
 void
@@ -1507,6 +1510,7 @@
 	screen = DefaultScreen(dpy);
 	root = RootWindow(dpy, screen);
 	fnt = drw_font_create(dpy, font);
+	fnt2 = drw_font_create(dpy, font2);
 	sw = DisplayWidth(dpy, screen);
 	sh = DisplayHeight(dpy, screen);
 	bh = fnt->h + 2;

Last edited by Nikiz (2014-08-30 18:52:10)

Offline

#1375 2014-08-30 21:17:02

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

ANOKNUSA wrote:

So I've been sloppily trying to get a couple things working, and my near-nonexistent C skills and knowledge have left me stumped. The first thing is this centerclock patch; I'd like the clock to be displayed on the far right of the statusbar---next to the status text---and leave the maximum width of the section at the number of characters in the clock text. I haven't quite figured out how to draw the clock text in its own section rather than replacing the status or window title text.

The second thing is to just change the window border color from dc.sel[ColBorder] to dc.norm[ColBG] in the monocle layout, to match the statusbar. This removes the visual distraction of the border, but leaves a few pixels of padding around the screen edge and below the statusbar text. If I've only got one window visible I'm in monocle mode anyway, so something like the better-borders and noborders patches seems like overkill. I've sort of figured out how this might work, but nothing reliable.  Like I said, I don't really grok C.

I'm using dwm 6.0. I've been fumbling around with this for two days, so if anyone's got some pointers, or is willing to make those modifications, I'd be grateful.

I could come up with something in the next week or so, maybe next two weeks. University is starting again on monday, so I have some others things to take care of first.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

Board footer

Powered by FluxBB