sites

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

dwm-taglayouts-6.8.diff (2049B)


      1 From 26a6205515ee7504e1f11e08aaf7d9de94ebc121 Mon Sep 17 00:00:00 2001
      2 From: Vedant Sule <sulevedant@gmail.com>
      3 Date: Sat, 25 Jul 2026 00:35:28 +0100
      4 Subject: [PATCH] Set initial previous layout
      5 
      6 Initialize the previous layout to switch to (default keybind:
      7 Mod+Shift). This fixes a bug with the patch which caused dwm to crash
      8 when attempting to switch to the previous layout without selecting one
      9 first.
     10 ---
     11  config.def.h |  1 +
     12  dwm.c        | 17 ++++++++++++-----
     13  2 files changed, 13 insertions(+), 5 deletions(-)
     14 
     15 diff --git a/config.def.h b/config.def.h
     16 index 81c3fc0..ca54ad7 100644
     17 --- a/config.def.h
     18 +++ b/config.def.h
     19 @@ -20,6 +20,7 @@ static const char *colors[][3]      = {
     20  
     21  /* tagging */
     22  static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
     23 +static const int taglayouts[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     24  
     25  static const Rule rules[] = {
     26  	/* xprop(1):
     27 diff --git a/dwm.c b/dwm.c
     28 index 53b9d4a..3179361 100644
     29 --- a/dwm.c
     30 +++ b/dwm.c
     31 @@ -652,9 +652,6 @@ createmon(void)
     32  	m->nmaster = nmaster;
     33  	m->showbar = showbar;
     34  	m->topbar = topbar;
     35 -	m->lt[0] = &layouts[0];
     36 -	m->lt[1] = &layouts[1 % LENGTH(layouts)];
     37 -	strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
     38  	m->pertag = ecalloc(1, sizeof(Pertag));
     39  	m->pertag->curtag = m->pertag->prevtag = 1;
     40  
     41 @@ -662,13 +659,23 @@ createmon(void)
     42  		m->pertag->nmasters[i] = m->nmaster;
     43  		m->pertag->mfacts[i] = m->mfact;
     44  
     45 -		m->pertag->ltidxs[i][0] = m->lt[0];
     46 -		m->pertag->ltidxs[i][1] = m->lt[1];
     47 +		if (i >= 1) {
     48 +			m->pertag->ltidxs[i][0] = &layouts[taglayouts[i - 1]];
     49 +			m->pertag->ltidxs[i][1] = &layouts[(taglayouts[i - 1] + 1) % LENGTH(layouts)];
     50 +		}
     51 +		else {
     52 +			m->pertag->ltidxs[i][0] = &layouts[0];
     53 +			m->pertag->ltidxs[i][1] = &layouts[1 % LENGTH(layouts)];
     54 +		}
     55  		m->pertag->sellts[i] = m->sellt;
     56  
     57  		m->pertag->showbars[i] = m->showbar;
     58  	}
     59  
     60 +	m->lt[0] = m->pertag->ltidxs[1][0];
     61 +	m->lt[1] = m->pertag->ltidxs[1][1];
     62 +	strncpy(m->ltsymbol, m->pertag->ltidxs[1][0]->symbol, sizeof m->ltsymbol);
     63 +
     64  	return m;
     65  }
     66  
     67 -- 
     68 2.54.0
     69