sites

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

dwm-twomonitorsetup-20240209-0b01a94.diff (3251B)


      1 From 0b01a947eeb893b85576e0117e98e455ff770558 Mon Sep 17 00:00:00 2001
      2 From: stojshic <stojshic@arch.pc>
      3 Date: Fri, 9 Feb 2024 20:56:34 +0100
      4 Subject: [PATCH] Two Monitor Setup
      5 
      6 ---
      7  dwm.c | 65 ++++++++++++++++++++++++++++++++++++++++++-----------------
      8  1 file changed, 46 insertions(+), 19 deletions(-)
      9 
     10 diff --git a/dwm.c b/dwm.c
     11 index f1d86b2..2234780 100644
     12 --- a/dwm.c
     13 +++ b/dwm.c
     14 @@ -160,7 +160,7 @@ static Monitor *createmon(void);
     15  static void destroynotify(XEvent *e);
     16  static void detach(Client *c);
     17  static void detachstack(Client *c);
     18 -static Monitor *dirtomon(int dir);
     19 +// static Monitor *dirtomon(int dir);
     20  static void drawbar(Monitor *m);
     21  static void drawbars(void);
     22  static void enternotify(XEvent *e);
     23 @@ -194,6 +194,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
     24  static void resizemouse(const Arg *arg);
     25  static void restack(Monitor *m);
     26  static void run(void);
     27 +static void runAutostart(void);
     28  static void scan(void);
     29  static int sendevent(Client *c, Atom proto);
     30  static void sendmon(Client *c, Monitor *m);
     31 @@ -680,6 +681,7 @@ detachstack(Client *c)
     32  	}
     33  }
     34  
     35 +/*
     36  Monitor *
     37  dirtomon(int dir)
     38  {
     39 @@ -694,7 +696,7 @@ dirtomon(int dir)
     40  		for (m = mons; m->next != selmon; m = m->next);
     41  	return m;
     42  }
     43 -
     44 +*/
     45  void
     46  drawbar(Monitor *m)
     47  {
     48 @@ -736,7 +738,8 @@ drawbar(Monitor *m)
     49  
     50  	if ((w = m->ww - tw - x) > bh) {
     51  		if (m->sel) {
     52 -			drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
     53 +			drw_setscheme(drw, scheme[SchemeNorm]);
     54 +			// drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
     55  			drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
     56  			if (m->sel->isfloating)
     57  				drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
     58 @@ -822,17 +825,22 @@ focusin(XEvent *e)
     59  }
     60  
     61  void
     62 -focusmon(const Arg *arg)
     63 -{
     64 -	Monitor *m;
     65 +focusmon(const Arg *arg) {
     66 +    Monitor *m = NULL;
     67  
     68 -	if (!mons->next)
     69 -		return;
     70 -	if ((m = dirtomon(arg->i)) == selmon)
     71 -		return;
     72 -	unfocus(selmon->sel, 0);
     73 -	selmon = m;
     74 -	focus(NULL);
     75 +    if (!mons->next)
     76 +        return;
     77 +
     78 +    if (arg->i > 0) {
     79 +        m = mons->next;
     80 +    } else if (arg->i < 0 && mons->next) {
     81 +        m = mons;
     82 +    }
     83 +
     84 +    if (m) {
     85 +        selmon = m;
     86 +        focus(NULL);
     87 +    }
     88  }
     89  
     90  void
     91 @@ -1390,6 +1398,12 @@ run(void)
     92  			handler[ev.type](&ev); /* call handler */
     93  }
     94  
     95 +void
     96 +runAutostart(void) {
     97 +	system("cd ~/.dwm; ./autostart_blocking.sh");
     98 +	system("cd ~/.dwm; ./autostart.sh &");
     99 +}
    100 +
    101  void
    102  scan(void)
    103  {
    104 @@ -1676,14 +1690,26 @@ tag(const Arg *arg)
    105  	}
    106  }
    107  
    108 -void
    109 -tagmon(const Arg *arg)
    110 -{
    111 -	if (!selmon->sel || !mons->next)
    112 -		return;
    113 -	sendmon(selmon->sel, dirtomon(arg->i));
    114 +void tagmon(const Arg *arg) {
    115 +    if (!selmon->sel || !mons->next)
    116 +        return;
    117 +
    118 +    Monitor *m;
    119 +
    120 +    if (arg->i > 0) {
    121 +        m = mons->next;  // Move to mon1
    122 +    } else if (arg->i < 0 && mons->next) {
    123 +        m = mons;  // Move to mon2
    124 +    } else {
    125 +        return; // Do nothing for arg->i == 0
    126 +    }
    127 +
    128 +    sendmon(selmon->sel, m);
    129 +    focus(NULL);
    130 +    arrange(selmon);
    131  }
    132  
    133 +
    134  void
    135  tile(Monitor *m)
    136  {
    137 @@ -2158,6 +2184,7 @@ main(int argc, char *argv[])
    138  		die("pledge");
    139  #endif /* __OpenBSD__ */
    140  	scan();
    141 +	runAutostart();
    142  	run();
    143  	cleanup();
    144  	XCloseDisplay(dpy);
    145 -- 
    146 2.43.0
    147