sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-alternativetags-6.2.diff (3014B)


      1 From 25aa44b5998a2aac840a0eecf9d8a479695b2577 Mon Sep 17 00:00:00 2001
      2 From: Piyush Pangtey <gokuvsvegita@gmail.com>
      3 Date: Sat, 13 Apr 2019 00:24:23 +0530
      4 Subject: [PATCH] alternative tags
      5 
      6 Having icons as tags sure makes dwm look awesome, but having tags number
      7 simplifies tags related operations. This patch introduces alternative
      8 tags which can be switched on the fly for the sole purpose of providing
      9 visual aid.
     10 
     11 Signed-off-by: Piyush Pangtey <gokuvsvegita@gmail.com>
     12 ---
     13  config.def.h |  2 ++
     14  dwm.c        | 14 ++++++++++++--
     15  2 files changed, 14 insertions(+), 2 deletions(-)
     16 
     17 diff --git a/config.def.h b/config.def.h
     18 index 1c0b587..e6c2565 100644
     19 --- a/config.def.h
     20 +++ b/config.def.h
     21 @@ -20,6 +20,7 @@ static const char *colors[][3]      = {
     22  
     23  /* tagging */
     24  static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
     25 +static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
     26  
     27  static const Rule rules[] = {
     28  	/* xprop(1):
     29 @@ -84,6 +85,7 @@ static Key keys[] = {
     30  	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
     31  	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
     32  	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
     33 +	{ MODKEY,                       XK_n,      togglealttag,   {0} },
     34  	TAGKEYS(                        XK_1,                      0)
     35  	TAGKEYS(                        XK_2,                      1)
     36  	TAGKEYS(                        XK_3,                      2)
     37 diff --git a/dwm.c b/dwm.c
     38 index 4465af1..ee292e1 100644
     39 --- a/dwm.c
     40 +++ b/dwm.c
     41 @@ -130,6 +130,7 @@ struct Monitor {
     42  	Monitor *next;
     43  	Window barwin;
     44  	const Layout *lt[2];
     45 +	unsigned int alttag;
     46  };
     47  
     48  typedef struct {
     49 @@ -209,6 +210,7 @@ static void spawn(const Arg *arg);
     50  static void tag(const Arg *arg);
     51  static void tagmon(const Arg *arg);
     52  static void tile(Monitor *);
     53 +static void togglealttag();
     54  static void togglebar(const Arg *arg);
     55  static void togglefloating(const Arg *arg);
     56  static void toggletag(const Arg *arg);
     57 @@ -695,7 +697,7 @@ dirtomon(int dir)
     58  void
     59  drawbar(Monitor *m)
     60  {
     61 -	int x, w, sw = 0;
     62 +	int x, w, wdelta, sw = 0;
     63  	int boxs = drw->fonts->h / 9;
     64  	int boxw = drw->fonts->h / 6 + 2;
     65  	unsigned int i, occ = 0, urg = 0;
     66 @@ -716,8 +718,9 @@ drawbar(Monitor *m)
     67  	x = 0;
     68  	for (i = 0; i < LENGTH(tags); i++) {
     69  		w = TEXTW(tags[i]);
     70 +		wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0;
     71  		drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
     72 -		drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
     73 +		drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), urg & 1 << i);
     74  		if (occ & 1 << i)
     75  			drw_rect(drw, x + boxs, boxs, boxw, boxw,
     76  				m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
     77 @@ -1696,6 +1699,13 @@ tile(Monitor *m)
     78  		}
     79  }
     80  
     81 +void
     82 +togglealttag()
     83 +{
     84 +	selmon->alttag = !selmon->alttag;
     85 +	drawbar(selmon);
     86 +}
     87 +
     88  void
     89  togglebar(const Arg *arg)
     90  {
     91 -- 
     92 2.21.0
     93