From 02b00575f138bc0b20489f9761938362292359c5 Mon Sep 17 00:00:00 2001 From: Yigit Colakoglu Date: Mon, 12 Apr 2021 20:15:03 +0300 Subject: [PATCH] Dwm Always Center --- .config/X11/xinitrc | 4 ++-- .local/src/dwm/dwm.c | 7 +++++++ .../patches/dwm-alwayscenter-20200625-f04cac6.diff | 12 ++++++++++++ .local/src/dwm/rules.h | 3 ++- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 .local/src/dwm/patches/dwm-alwayscenter-20200625-f04cac6.diff diff --git a/.config/X11/xinitrc b/.config/X11/xinitrc index e1044bef..f4a82371 100755 --- a/.config/X11/xinitrc +++ b/.config/X11/xinitrc @@ -64,7 +64,7 @@ xset dpms 600 600 600 --no-unmount --no-gui & -$BROWSER & +#$BROWSER & #pass 2> /dev/null > /dev/null && qtpass & redshift -x 2> /dev/null > /dev/null @@ -81,7 +81,7 @@ do fi dwmblocks > $XDG_RUNTIME_DIR/dwmblocks.out 2> $XDG_RUNTIME_DIR/dwmblocks.err & - exec dwm > $XDG_RUNTIME_DIR/dwm.log 2> $XDG_RUNTIME_DIR/dwm.err + dwm > $XDG_RUNTIME_DIR/dwm.log 2> $XDG_RUNTIME_DIR/dwm.err sleep 0.5 done diff --git a/.local/src/dwm/dwm.c b/.local/src/dwm/dwm.c index 9456627c..9d343530 100644 --- a/.local/src/dwm/dwm.c +++ b/.local/src/dwm/dwm.c @@ -367,6 +367,13 @@ applyrules(Client *c) c->mon = m; if (c->isfloating && r->floatpos) setfloatpos(c, r->floatpos); + else{ + c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; + c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; + } + }else{ + c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; + c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; } } if (ch.res_class) diff --git a/.local/src/dwm/patches/dwm-alwayscenter-20200625-f04cac6.diff b/.local/src/dwm/patches/dwm-alwayscenter-20200625-f04cac6.diff new file mode 100644 index 00000000..03ea9ef2 --- /dev/null +++ b/.local/src/dwm/patches/dwm-alwayscenter-20200625-f04cac6.diff @@ -0,0 +1,12 @@ +diff -up dwm/dwm.c dwmmod/dwm.c +--- dwm/dwm.c 2020-06-25 00:21:30.383692180 -0300 ++++ dwmmod/dwm.c 2020-06-25 00:20:35.643692330 -0300 +@@ -1057,6 +1057,8 @@ manage(Window w, XWindowAttributes *wa) + updatewindowtype(c); + updatesizehints(c); + updatewmhints(c); ++ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; ++ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; + XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); + grabbuttons(c, 0); + if (!c->isfloating) diff --git a/.local/src/dwm/rules.h b/.local/src/dwm/rules.h index 16188608..971e2ccd 100644 --- a/.local/src/dwm/rules.h +++ b/.local/src/dwm/rules.h @@ -43,9 +43,10 @@ static const Rule rules[] = { { NULL , "spfile" , NULL , SPTAG(3) , 1 , NULL , 0 , 0 , -1 }, { NULL , "spmusic" , NULL , SPTAG(4) , 1 , NULL , 0 , 0 , -1 }, { NULL , "spcal" , NULL , SPTAG(5) , 1 , NULL , 0 , 0 , -1 }, -{ NULL , "sxiv" , NULL , 0 , 1 , "100% 1% 600W 350H" , 0 , 0 , -1 }, +{ NULL , "sxiv" , NULL , 0 , 1 , "100% 1% 600W 350H" , 1 , 0 , -1 }, { NULL , "Kunst" , NULL , 0 , 1 , "100% 1% 150W 150H" , 0 , 0 , -1 }, { NULL , NULL , "SimCrop" , 0 , 1 , "50% 50% 800W 500H" , 0 ,0 , -1 }, +//{ NULL , NULL , NULL , 0 , 1 , NULL , 0 ,0 , -1 }, }; #endif /* rules_h */