aboutsummaryrefslogtreecommitdiff
path: root/dwm
diff options
context:
space:
mode:
Diffstat (limited to 'dwm')
-rw-r--r--dwm/config.def.h8
-rw-r--r--dwm/config.h8
-rw-r--r--dwm/dwm.c50
-rw-r--r--dwm/patches/dwm-holdbar-6.2.diff129
4 files changed, 189 insertions, 6 deletions
diff --git a/dwm/config.def.h b/dwm/config.def.h
index abb5b51..4930269 100644
--- a/dwm/config.def.h
+++ b/dwm/config.def.h
@@ -4,7 +4,7 @@
static const unsigned int borderpx = 0; /* border pixel of windows */
static const unsigned int gappx = 15; /* gaps between windows */
static const unsigned int snap = 32; /* snap pixel */
-static const int showbar = 1; /* 0 means no bar */
+static const int showbar = 0; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const int splitstatus = 1; /* 1 for split status items */
static const char *splitdelim = ";"; /* Character used for separating status */
@@ -63,6 +63,7 @@ static const Layout layouts[] = {
{MODKEY | ControlMask, KEY, toggleview, {.ui = 1 << TAG}}, \
{MODKEY | ShiftMask, KEY, tag, {.ui = 1 << TAG}}, \
{MODKEY | ControlMask | ShiftMask, KEY, toggletag, {.ui = 1 << TAG}},
+#define HOLDKEY XK_b
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) \
@@ -91,13 +92,13 @@ static const char *previouscmd[] = {"adb", "shell", "input",
static const char *qalccmd[] = {
"dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb",
col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf",
- col_gray4, "-C", "-l", "1", NULL};
+ col_gray4, "-C", "-l", "1", NULL};
static const Key keys[] = {
/* modifier key function argument */
{MODKEY, XK_p, spawn, {.v = dmenucmd}},
{MODKEY | ShiftMask, XK_Return, spawn, {.v = termcmd}},
- {MODKEY, XK_b, togglebar, {0}},
+ {MODKEY, XK_q, togglebar, {0}},
{MODKEY, XK_j, focusstack, {.i = +1}},
{MODKEY, XK_k, focusstack, {.i = -1}},
{MODKEY, XK_i, incnmaster, {.i = +1}},
@@ -122,6 +123,7 @@ static const Key keys[] = {
{MODKEY | ShiftMask, XK_period, tagmon, {.i = +1}},
TAGKEYS(XK_1, 0) TAGKEYS(XK_2, 1) TAGKEYS(XK_3, 2) TAGKEYS(XK_4, 3)
TAGKEYS(XK_5, 4) TAGKEYS(XK_6, 5){MODKEY | ShiftMask, XK_q, quit, {0}},
+ {MODKEY, HOLDKEY, holdbar, {0}},
{0, XK_Print, spawn, {.v = prtscrcmd}},
{MODKEY | ShiftMask, XK_h, spawn, {.v = kblayoutcmd}},
{MODKEY | ShiftMask, XK_f, spawn, {.v = firefoxcmd}},
diff --git a/dwm/config.h b/dwm/config.h
index abb5b51..4930269 100644
--- a/dwm/config.h
+++ b/dwm/config.h
@@ -4,7 +4,7 @@
static const unsigned int borderpx = 0; /* border pixel of windows */
static const unsigned int gappx = 15; /* gaps between windows */
static const unsigned int snap = 32; /* snap pixel */
-static const int showbar = 1; /* 0 means no bar */
+static const int showbar = 0; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const int splitstatus = 1; /* 1 for split status items */
static const char *splitdelim = ";"; /* Character used for separating status */
@@ -63,6 +63,7 @@ static const Layout layouts[] = {
{MODKEY | ControlMask, KEY, toggleview, {.ui = 1 << TAG}}, \
{MODKEY | ShiftMask, KEY, tag, {.ui = 1 << TAG}}, \
{MODKEY | ControlMask | ShiftMask, KEY, toggletag, {.ui = 1 << TAG}},
+#define HOLDKEY XK_b
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) \
@@ -91,13 +92,13 @@ static const char *previouscmd[] = {"adb", "shell", "input",
static const char *qalccmd[] = {
"dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb",
col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf",
- col_gray4, "-C", "-l", "1", NULL};
+ col_gray4, "-C", "-l", "1", NULL};
static const Key keys[] = {
/* modifier key function argument */
{MODKEY, XK_p, spawn, {.v = dmenucmd}},
{MODKEY | ShiftMask, XK_Return, spawn, {.v = termcmd}},
- {MODKEY, XK_b, togglebar, {0}},
+ {MODKEY, XK_q, togglebar, {0}},
{MODKEY, XK_j, focusstack, {.i = +1}},
{MODKEY, XK_k, focusstack, {.i = -1}},
{MODKEY, XK_i, incnmaster, {.i = +1}},
@@ -122,6 +123,7 @@ static const Key keys[] = {
{MODKEY | ShiftMask, XK_period, tagmon, {.i = +1}},
TAGKEYS(XK_1, 0) TAGKEYS(XK_2, 1) TAGKEYS(XK_3, 2) TAGKEYS(XK_4, 3)
TAGKEYS(XK_5, 4) TAGKEYS(XK_6, 5){MODKEY | ShiftMask, XK_q, quit, {0}},
+ {MODKEY, HOLDKEY, holdbar, {0}},
{0, XK_Print, spawn, {.v = prtscrcmd}},
{MODKEY | ShiftMask, XK_h, spawn, {.v = kblayoutcmd}},
{MODKEY | ShiftMask, XK_f, spawn, {.v = firefoxcmd}},
diff --git a/dwm/dwm.c b/dwm/dwm.c
index 5552e2f..c736fd7 100644
--- a/dwm/dwm.c
+++ b/dwm/dwm.c
@@ -180,6 +180,7 @@ static void grabbuttons(Client *c, int focused);
static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
+static void keyrelease(XEvent *e);
static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
@@ -214,6 +215,7 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
+static void holdbar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
@@ -221,6 +223,7 @@ static void unfocus(Client *c, int setfocus);
static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e);
static void updatebarpos(Monitor *m);
+static void updateholdbarpos(Monitor *m);
static void updatebars(void);
static void updateclientlist(void);
static int updategeom(void);
@@ -251,6 +254,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress,
+ [ButtonRelease] = keyrelease,
[ClientMessage] = clientmessage,
[ConfigureRequest] = configurerequest,
[ConfigureNotify] = configurenotify,
@@ -258,6 +262,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[EnterNotify] = enternotify,
[Expose] = expose,
[FocusIn] = focusin,
+ [KeyRelease] = keyrelease,
[KeyPress] = keypress,
[MappingNotify] = mappingnotify,
[MapRequest] = maprequest,
@@ -295,6 +300,51 @@ struct Pertag {
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
/* function implementations */
+
+
+void
+holdbar(const Arg *arg)
+{
+ selmon->showbar = 1;
+ updateholdbarpos(selmon);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
+}
+
+
+void
+keyrelease(XEvent *e)
+{
+ if (XEventsQueued(dpy, QueuedAfterReading)) {
+ XEvent ne;
+ XPeekEvent(dpy, &ne);
+
+ if (ne.type == KeyPress && ne.xkey.time == e->xkey.time &&
+ ne.xkey.keycode == e->xkey.keycode) {
+ XNextEvent(dpy, &ne);
+ return;
+ }
+ }
+ if (e->xkey.keycode == XKeysymToKeycode(dpy, HOLDKEY)) {
+ selmon->showbar = 0;
+ updateholdbarpos(selmon);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
+ arrange(selmon);
+ }
+}
+
+void
+updateholdbarpos(Monitor *m)
+{
+ m->wy = m->my;
+ m->wh = m->mh;
+ if (m->showbar) {
+ m->by = m->topbar ? m->wy : m->wy + m->wh - bh;
+ m->wy = m->topbar ? m->wy - bh + bh : m->wy;
+ } else {
+ m->by = -bh;
+ }
+}
+
void
applyrules(Client *c)
{
diff --git a/dwm/patches/dwm-holdbar-6.2.diff b/dwm/patches/dwm-holdbar-6.2.diff
new file mode 100644
index 0000000..0e2b6e1
--- /dev/null
+++ b/dwm/patches/dwm-holdbar-6.2.diff
@@ -0,0 +1,129 @@
+From 58507fca3c3c334f540700c5ed81815d9335138e Mon Sep 17 00:00:00 2001
+From: Nihal Jere <noocsharp@gmail.com>
+Date: Thu, 12 Mar 2020 10:16:48 -0500
+Subject: [PATCH] holdbar: fixed bar flickering caused by repeated key events
+
+---
+ config.def.h | 2 ++
+ dwm.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 52 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..0e19b5d 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -50,6 +50,7 @@ static const Layout layouts[] = {
+ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
+ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
+ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
++#define HOLDKEY 0 // replace 0 with the keysym to activate holdbar
+
+ /* helper for spawning shell commands in the pre dwm-5.0 fashion */
+ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
+@@ -94,6 +95,7 @@ static Key keys[] = {
+ TAGKEYS( XK_8, 7)
+ TAGKEYS( XK_9, 8)
+ { MODKEY|ShiftMask, XK_q, quit, {0} },
++ { 0, HOLDKEY, holdbar, {0} },
+ };
+
+ /* button definitions */
+diff --git a/dwm.c b/dwm.c
+index 4465af1..9437707 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -176,6 +176,7 @@ static void grabbuttons(Client *c, int focused);
+ static void grabkeys(void);
+ static void incnmaster(const Arg *arg);
+ static void keypress(XEvent *e);
++static void keyrelease(XEvent *e);
+ static void killclient(const Arg *arg);
+ static void manage(Window w, XWindowAttributes *wa);
+ static void mappingnotify(XEvent *e);
+@@ -210,6 +211,7 @@ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
++static void holdbar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+@@ -217,6 +219,7 @@ static void unfocus(Client *c, int setfocus);
+ static void unmanage(Client *c, int destroyed);
+ static void unmapnotify(XEvent *e);
+ static void updatebarpos(Monitor *m);
++static void updateholdbarpos(Monitor *m);
+ static void updatebars(void);
+ static void updateclientlist(void);
+ static int updategeom(void);
+@@ -245,6 +248,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *);
+ static unsigned int numlockmask = 0;
+ static void (*handler[LASTEvent]) (XEvent *) = {
+ [ButtonPress] = buttonpress,
++ [ButtonRelease] = keyrelease,
+ [ClientMessage] = clientmessage,
+ [ConfigureRequest] = configurerequest,
+ [ConfigureNotify] = configurenotify,
+@@ -252,6 +256,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
+ [EnterNotify] = enternotify,
+ [Expose] = expose,
+ [FocusIn] = focusin,
++ [KeyRelease] = keyrelease,
+ [KeyPress] = keypress,
+ [MappingNotify] = mappingnotify,
+ [MapRequest] = maprequest,
+@@ -275,6 +280,51 @@ static Window root, wmcheckwin;
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+ /* function implementations */
++
++
++void
++holdbar(const Arg *arg)
++{
++ selmon->showbar = 1;
++ updateholdbarpos(selmon);
++ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
++}
++
++
++void
++keyrelease(XEvent *e)
++{
++ if (XEventsQueued(dpy, QueuedAfterReading)) {
++ XEvent ne;
++ XPeekEvent(dpy, &ne);
++
++ if (ne.type == KeyPress && ne.xkey.time == e->xkey.time &&
++ ne.xkey.keycode == e->xkey.keycode) {
++ XNextEvent(dpy, &ne);
++ return;
++ }
++ }
++ if (e->xkey.keycode == XKeysymToKeycode(dpy, HOLDKEY)) {
++ selmon->showbar = 0;
++ updateholdbarpos(selmon);
++ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
++ arrange(selmon);
++ }
++}
++
++void
++updateholdbarpos(Monitor *m)
++{
++ m->wy = m->my;
++ m->wh = m->mh;
++ if (m->showbar) {
++ m->by = m->topbar ? m->wy : m->wy + m->wh - bh;
++ m->wy = m->topbar ? m->wy - bh + bh : m->wy;
++ } else {
++ m->by = -bh;
++ }
++}
++
+ void
+ applyrules(Client *c)
+ {
+--
+2.25.1
+