Skip to content

Instantly share code, notes, and snippets.

@ropery
Created November 2, 2011 16:52
Show Gist options
  • Save ropery/1334192 to your computer and use it in GitHub Desktop.
Save ropery/1334192 to your computer and use it in GitHub Desktop.
activetags.patch for dwm 5.9
Depends on urgcolors.patch
Changes the way tags are displayed in the dwm bar:
* Selected tags are displayed as usual.
* Urgent tags are displayed in reverted dc.urg colors.
* Other tags are not diaplayed in the bar.
* The little squares are not drawn.
Tip: make every tag equally long, using a monospaced font.
--- a/dwm.c 2011-07-11 03:53:25.848996476 +0000
+++ b/dwm.c 2011-07-11 09:18:35.203757084 +0000
@@ -129,6 +129,7 @@ struct Monitor {
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
+ unsigned int drawntags; /* tags drawn on bar */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@@ -434,7 +435,8 @@ buttonpress(XEvent *e) {
if(ev->window == selmon->barwin) {
i = x = 0;
do {
- x += TEXTW(tags[i]);
+ if(selmon->drawntags & 1 << i)
+ x += TEXTW(tags[i]);
} while(ev->x >= x && ++i < LENGTH(tags));
if(i < LENGTH(tags)) {
click = ClkTagBar;
@@ -736,11 +738,20 @@ drawbar(Monitor *m) {
dc.x = 0;
+ m->drawntags = 0;
for(i = 0; i < LENGTH(tags); i++) {
dc.w = TEXTW(tags[i]);
- col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
- drawtext(tags[i], col, urg & 1 << i);
- drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
- occ & 1 << i, urg & 1 << i, col);
- dc.x += dc.w;
+ /* draw selected tags */
+ if(m->tagset[m->seltags] & 1 << i) {
+ drawtext(tags[i], dc.sel, False);
+ m->drawntags |= 1 << i;
+ dc.x += dc.w;
+ }
+ /* draw urgent tags */
+ else if(urg & 1 << i) {
+ drawtext(tags[i], dc.urg, True);
+ m->drawntags |= 1 << i;
+ dc.x += dc.w;
+ }
+ /* do not draw other tags */
}
dc.w = blw = TEXTW(m->ltsymbol);
drawtext(m->ltsymbol, dc.norm, False);
dynamictitle.patch for dwm 5.9
Changes the way window titles are displayed in the dwm bar:
* The "visual length" of the title is dynamically adjusted to just long
enough to hold the window title.
diff -up a/dwm.c b/dwm.c
--- a/dwm.c 2011-07-11 10:18:58.794920643 +0000
+++ b/dwm.c 2011-07-11 10:42:54.812150418 +0000
@@ -761,8 +761,15 @@ drawbar(Monitor *m) {
dc.x = x;
if(m->sel) {
col = m == selmon ? dc.sel : dc.norm;
+ unsigned int w = dc.w;
+ dc.w = MIN(dc.w, TEXTW(m->sel->name));
drawtext(m->sel->name, col, False);
drawsquare(m->sel->isfixed, m->sel->isfloating, False, col);
+ if (dc.w < w) {
+ dc.x += dc.w;
+ dc.w = w - dc.w;
+ drawtext(NULL, dc.norm, False);
+ }
}
else
drawtext(NULL, dc.norm, False);
urgcolors.patch for dwm 5.9
Defines dc.urg in the same manner as dc.norm and dc.sel are defined.
To use this, put the following definitions in your config.h:
static const char urgbordercolor[] = "#ff0000";
static const char urgbgcolor[] = "#ffffff";
static const char urgfgcolor[] = "#ff0000";
--- a/dwm.c 2011-07-11 03:53:25.848996476 +0000
+++ b/dwm.c 2011-07-11 09:27:48.497175295 +0000
@@ -99,6 +99,7 @@ typedef struct {
int x, y, w, h;
unsigned long norm[ColLast];
unsigned long sel[ColLast];
+ unsigned long urg[ColLast];
Drawable drawable;
GC gc;
struct {
@@ -1556,6 +1557,9 @@ setup(void) {
dc.sel[ColBorder] = getcolor(selbordercolor);
dc.sel[ColBG] = getcolor(selbgcolor);
dc.sel[ColFG] = getcolor(selfgcolor);
+ dc.urg[ColBorder] = getcolor(urgbordercolor);
+ dc.urg[ColBG] = getcolor(urgbgcolor);
+ dc.urg[ColFG] = getcolor(urgfgcolor);
dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
dc.gc = XCreateGC(dpy, root, 0, NULL);
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment