From dd94cb00e5b1d42ac672cb838a01d085c73c14e7 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Fri, 18 Jun 2021 18:38:44 -0400 Subject: [PATCH] Initial commit * Apply patches attachbottom, cursorwarp, fakefullscreen. * Add personalizations --- .gitignore | 2 ++ Makefile | 5 +---- config.def.h => config.h | 48 +++++++++++++++++++++++++++++++--------- dwm.c | 48 +++++++++++++++------------------------- 4 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 .gitignore rename config.def.h => config.h (66%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..095e840 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +dwm diff --git a/Makefile b/Makefile index 77bcbc0..9ae64c5 100644 --- a/Makefile +++ b/Makefile @@ -19,9 +19,6 @@ options: ${OBJ}: config.h config.mk -config.h: - cp config.def.h $@ - dwm: ${OBJ} ${CC} -o $@ ${OBJ} ${LDFLAGS} @@ -30,7 +27,7 @@ clean: dist: clean mkdir -p dwm-${VERSION} - cp -R LICENSE Makefile README config.def.h config.mk\ + cp -R LICENSE Makefile README config.mk\ dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION} tar -cf dwm-${VERSION}.tar dwm-${VERSION} gzip dwm-${VERSION}.tar diff --git a/config.def.h b/config.h similarity index 66% rename from config.def.h rename to config.h index 1c0b587..a30104d 100644 --- a/config.def.h +++ b/config.h @@ -5,8 +5,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "monospace:size=10" }; -static const char dmenufont[] = "monospace:size=10"; +static const char *fonts[] = { "JetBrainsMono Medium NF:pixelsize=14:antialias=true:autohint=true" }; +static const char dmenufont[] = "JetBrainsMono Medium NF:pixelsize=14:antialias=true:autohint=true"; static const char col_gray1[] = "#222222"; static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; @@ -19,22 +19,24 @@ static const char *colors[][3] = { }; /* tagging */ -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +static const char *tags[] = { "1", "2", "3", "4", "5" }; static const Rule rules[] = { /* xprop(1): * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask isfloating monitor */ - { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + /* class instance title tags mask isfloating monitor */ + { "Gimp", NULL, NULL, 0, 1, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + { "St", NULL, NULL, 0, 0, -1 }, + { NULL, NULL, "Event Tester", 0, 0, -1 }, /* xev */ }; /* layout(s) */ -static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const float mfact = 0.5; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ -static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ +static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ static const Layout layouts[] = { /* symbol arrange function */ @@ -44,20 +46,21 @@ static const Layout layouts[] = { }; /* key definitions */ -#define MODKEY Mod1Mask +#define MODKEY Mod4Mask #define TAGKEYS(KEY,TAG) \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, -/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +/* helper for spawning shell and emacs commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } +#define EMACS(cmd) { .v = (const char*[]){ "/bin/emacsclient", "-ce", cmd, NULL } } /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *termcmd[] = { "st", NULL }; +static const char *termcmd[] = { "tmuxt" }; static Key keys[] = { /* modifier key function argument */ @@ -94,6 +97,29 @@ static Key keys[] = { TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) { MODKEY|ShiftMask, XK_q, quit, {0} }, + /***************************************************************/ + { MODKEY|ShiftMask, XK_p, spawn, SHCMD("passmenu") }, + { MODKEY, XK_Escape, spawn, SHCMD("slock") }, + /***************************************************************/ + { MODKEY|ControlMask, XK_Return, spawn, SHCMD("emacsclient -c") }, + { MODKEY|ControlMask, XK_1, spawn, EMACS("(progn (switch-to-buffer \"*scratch*\") (mu4e))") }, + { MODKEY|ControlMask, XK_2, spawn, EMACS("(acheam-irc)") }, + { MODKEY|ControlMask, XK_3, spawn, EMACS("(elfeed)") }, + { MODKEY|ControlMask, XK_4, spawn, EMACS("(acheam-calendar)") }, + { MODKEY|ControlMask, XK_5, spawn, EMACS("(progn (calc) (windmove-up) (delete-window))") }, + { MODKEY|ControlMask, XK_o, spawn, SHCMD("bookmarks") }, + { MODKEY|ControlMask, XK_p, spawn, SHCMD("chorizo") }, + /***************************************************************/ + { 0, XF86XK_AudioLowerVolume, spawn, SHCMD("setter audio -5") }, + { 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("setter audio +5") }, + { 0, XF86XK_AudioMute, spawn, SHCMD("setter audio +5") }, + { 0, XF86XK_MonBrightnessDown, spawn, SHCMD("setter brightness -5") }, + { 0, XF86XK_MonBrightnessUp, spawn, SHCMD("setter brightness +5") }, + /***************************************************************/ + { MODKEY|ControlMask, XK_h, spawn, SHCMD("xdotool keyup h key --clearmodifiers Left") }, + { MODKEY|ControlMask, XK_j, spawn, SHCMD("xdotool keyup j key --clearmodifiers Down") }, + { MODKEY|ControlMask, XK_k, spawn, SHCMD("xdotool keyup k key --clearmodifiers Up") }, + { MODKEY|ControlMask, XK_l, spawn, SHCMD("xdotool keyup l key --clearmodifiers Right") }, }; /* button definitions */ diff --git a/dwm.c b/dwm.c index b0b3466..2202d3b 100644 --- a/dwm.c +++ b/dwm.c @@ -40,6 +40,7 @@ #include #endif /* XINERAMA */ #include +#include #include "drw.h" #include "util.h" @@ -147,6 +148,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac static void arrange(Monitor *m); static void arrangemon(Monitor *m); static void attach(Client *c); +static void attachbottom(Client *c); static void attachstack(Client *c); static void buttonpress(XEvent *e); static void checkotherwm(void); @@ -407,6 +409,15 @@ attach(Client *c) c->mon->clients = c; } +void +attachbottom(Client *c) +{ + Client **tc; + c->next = NULL; + for (tc = &c->mon->clients; *tc; tc = &(*tc)->next); + *tc = c; +} + void attachstack(Client *c) { @@ -522,7 +533,7 @@ clientmessage(XEvent *e) if (cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen]) setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ - || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); + || cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */)); } else if (cme->message_type == netatom[NetActiveWindow]) { if (c != selmon->sel && !c->isurgent) seturgent(c, 1); @@ -552,7 +563,6 @@ void configurenotify(XEvent *e) { Monitor *m; - Client *c; XConfigureEvent *ev = &e->xconfigure; int dirty; @@ -565,9 +575,6 @@ configurenotify(XEvent *e) drw_resize(drw, sw, bh); updatebars(); for (m = mons; m; m = m->next) { - for (c = m->clients; c; c = c->next) - if (c->isfullscreen) - resizeclient(c, m->mx, m->my, m->mw, m->mh); XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); } focus(NULL); @@ -835,7 +842,7 @@ focusstack(const Arg *arg) { Client *c = NULL, *i; - if (!selmon->sel || selmon->sel->isfullscreen) + if (!selmon->sel) return; if (arg->i > 0) { for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); @@ -1063,7 +1070,7 @@ manage(Window w, XWindowAttributes *wa) c->isfloating = c->oldstate = trans != None || c->isfixed; if (c->isfloating) XRaiseWindow(dpy, c->win); - attach(c); + attachbottom(c); attachstack(c); XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, (unsigned char *) &(c->win), 1); @@ -1144,8 +1151,6 @@ movemouse(const Arg *arg) if (!(c = selmon->sel)) return; - if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ - return; restack(selmon); ocx = c->x; ocy = c->y; @@ -1299,8 +1304,6 @@ resizemouse(const Arg *arg) if (!(c = selmon->sel)) return; - if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */ - return; restack(selmon); ocx = c->x; ocy = c->y; @@ -1418,7 +1421,7 @@ sendmon(Client *c, Monitor *m) detachstack(c); c->mon = m; c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ - attach(c); + attachbottom(c); attachstack(c); focus(NULL); arrange(NULL); @@ -1477,24 +1480,10 @@ setfullscreen(Client *c, int fullscreen) XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); c->isfullscreen = 1; - c->oldstate = c->isfloating; - c->oldbw = c->bw; - c->bw = 0; - c->isfloating = 1; - resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); - XRaiseWindow(dpy, c->win); } else if (!fullscreen && c->isfullscreen){ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char*)0, 0); c->isfullscreen = 0; - c->isfloating = c->oldstate; - c->bw = c->oldbw; - c->x = c->oldx; - c->y = c->oldy; - c->w = c->oldw; - c->h = c->oldh; - resizeclient(c, c->x, c->y, c->w, c->h); - arrange(c->mon); } } @@ -1619,7 +1608,7 @@ showhide(Client *c) if (ISVISIBLE(c)) { /* show clients top down */ XMoveWindow(dpy, c->win, c->x, c->y); - if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) + if (!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) resize(c, c->x, c->y, c->w, c->h, 0); showhide(c->snext); } else { @@ -1713,8 +1702,6 @@ togglefloating(const Arg *arg) { if (!selmon->sel) return; - if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ - return; selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; if (selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, @@ -1782,6 +1769,7 @@ unmanage(Client *c, int destroyed) XUngrabServer(dpy); } free(c); + focus(NULL); updateclientlist(); arrange(m); @@ -1900,7 +1888,7 @@ updategeom(void) m->clients = c->next; detachstack(c); c->mon = mons; - attach(c); + attachbottom(c); attachstack(c); } if (m == selmon) -- 2.39.2