summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2021-02-15 12:08:53 -0500
committerJon Santmyer <jon@jonsantmyer.com>2021-02-15 12:08:53 -0500
commitb4db5ddec79bad3225a21a3832bb8619c9b99a8d (patch)
tree10d7251a7d5e5df539eb6bddf65fbf60aff05c8a
parent684f6de00bb19a3c4e2a7a114d685b3196c7c403 (diff)
downloaddwm-b4db5ddec79bad3225a21a3832bb8619c9b99a8d.tar.gz
dwm-b4db5ddec79bad3225a21a3832bb8619c9b99a8d.tar.bz2
dwm-b4db5ddec79bad3225a21a3832bb8619c9b99a8d.zip
add scratchpad, change keybinds for passmenu and layout
-rw-r--r--config.def.h42
-rw-r--r--dwm.c37
-rw-r--r--patches/scratchpad.diff90
3 files changed, 148 insertions, 21 deletions
diff --git a/config.def.h b/config.def.h
index 575ded9..ab07e6e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -23,8 +23,8 @@ enum showtab_modes { showtab_never, showtab_auto, showtab_nmodes, showtab_always
static const int showtab = showtab_auto; /* Default tab bar show mode */
static const int toptab = False; /* False means bottom tab bar */
-static const char *fonts[] = { "Liberation Mono:size=10" };
-static const char dmenufont[] = "Liberation Mono:size=10";
+static const char *fonts[] = { "Liberation Mono:size=8" };
+static const char dmenufont[] = "Liberation Mono:size=8";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
@@ -104,13 +104,11 @@ static const char *dmenucmd[] = { "rofi", "-show", "drun", "-icon-theme" ,"'Pap
static const char *termcmd[] = { "st", NULL };
static const char *browsercmd[] = { "librewolf", NULL };
-static const char *volume_lower[] = { "/bin/sh", "-c", "${HOME}/.dwm/scripts/volume-change.sh -5%", NULL };
-static const char *volume_raise[] = { "/bin/sh", "-c", "${HOME}/.dwm/scripts/volume-change.sh +5%", NULL };
-static const char *volume_mute[] = { "/bin/sh", "-c", "${HOME}/.dwm/scripts/volume-change.sh mute", NULL };
+#define VOLUME_RAISE "${HOME}/.dwm/scripts/volume-change.sh +5%"
+#define VOLUME_LOWER "${HOME}/.dwm/scripts/volume-change.sh -5%"
+#define VOLUME_MUTE "${HOME}/.dwm/scripts/volume-change.sh mute"
-static const char *passmenu[] = { "/bin/sh", "-c", "${HOME}/.local/bin/passmenu-unified.sh", NULL };
-static const char *neomutt[] = { "/usr/bin/st", "neomutt", NULL };
-static const char *newsboat[] = { "/usr/bin/st", "newsboat", NULL };
+static const char *scratchpadcmd[] = { "st", "-t", "scratchpad", "-g", "120x34", NULL };
static Key keys[] = {
/* modifier key function argument */
@@ -119,20 +117,26 @@ static Key keys[] = {
{ MODKEY, XK_d, spawn, { .v = dmenucmd } },
{ MODKEY, XK_Return, spawn, { .v = termcmd } },
{ MODKEY, XK_w, spawn, { .v = browsercmd } },
- { MODKEY, XK_p, spawn, { .v = passmenu } },
- { MODKEY, XK_n, spawn, { .v = newsboat } },
- { MODKEY, XK_m, spawn, { .v = neomutt } },
+ { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
+ { MODKEY, XK_p, spawn, SHCMD("passmenu") },
+ { MODKEY, XK_o, spawn, SHCMD("passmenu-otp") },
//Multimedia
#include <X11/XF86keysym.h>
- { 0, XF86XK_AudioLowerVolume, spawn, { .v = volume_lower } },
- { 0, XF86XK_AudioRaiseVolume, spawn, { .v = volume_raise } },
- { 0, XF86XK_AudioMute, spawn, { .v = volume_mute } },
+ { 0, XF86XK_AudioLowerVolume, spawn, SHCMD(VOLUME_LOWER) },
+ { 0, XF86XK_AudioRaiseVolume, spawn, SHCMD(VOLUME_RAISE) },
+ { 0, XF86XK_AudioMute, spawn, SHCMD(VOLUME_MUTE) },
//Layout
- { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
- { MODKEY, XK_s, setlayout, {.v = &layouts[2]} },
- { MODKEY, XK_m, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_s, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[1]} },
+
+ //Layout Adjustment
+ { MODKEY, XK_Right, incnmaster, {.i = +1 } },
+ { MODKEY, XK_Left, incnmaster, {.i = -1 } },
+ { MODKEY, XK_Up, zoom, {0} },
+ { MODKEY, XK_Tab, view, {0} },
//Gaps
{ MODKEY|Mod1Mask, XK_u, incrgaps, {.i = +1 } },
@@ -155,12 +159,8 @@ static Key keys[] = {
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
- { MODKEY, XK_p, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
- { MODKEY|ShiftMask, XK_Return, zoom, {0} },
- { MODKEY, XK_Tab, view, {0} },
{ MODKEY, XK_q, killclient, {0} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
diff --git a/dwm.c b/dwm.c
index 70920e6..67f70ad 100644
--- a/dwm.c
+++ b/dwm.c
@@ -267,6 +267,7 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
+static void togglescratch(const Arg *arg);
static void togglefullscr(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
@@ -338,6 +339,7 @@ static Drw *drw;
static Monitor *mons, *selmon;
static Window root, wmcheckwin;
+
static xcb_connection_t *xcon;
/* configuration, allows nested code to access above variables */
@@ -345,6 +347,7 @@ static xcb_connection_t *xcon;
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+static unsigned int scratchtag = 1 << LENGTH(tags);
/* dwm will keep pid's of processes from autostart array and kill them at quit */
static pid_t *autostart_pids;
@@ -1435,6 +1438,15 @@ manage(Window w, XWindowAttributes *wa)
&& (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
c->bw = borderpx;
+ selmon->tagset[selmon->seltags] &= ~scratchtag;
+ if (!strcmp(c->name, "scratchpad")) {
+ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
+ c->isfloating = True;
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
+ }
+
+
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
@@ -2133,6 +2145,8 @@ spawn(const Arg *arg)
{
if (arg->v == dmenucmd)
dmenumon[0] = '0' + selmon->num;
+ selmon->tagset[selmon->seltags] &= ~scratchtag;
+
if (fork() == 0) {
if (dpy)
close(ConnectionNumber(dpy));
@@ -2215,6 +2229,29 @@ togglefullscr(const Arg *arg)
}
void
+togglescratch(const Arg *arg)
+{
+ Client *c;
+ unsigned int found = 0;
+
+ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
+ if (found) {
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
+ if (newtagset) {
+ selmon->tagset[selmon->seltags] = newtagset;
+ focus(NULL);
+ arrange(selmon);
+ }
+ if (ISVISIBLE(c)) {
+ focus(c);
+ restack(selmon);
+ }
+ } else
+ spawn(arg);
+}
+
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;
diff --git a/patches/scratchpad.diff b/patches/scratchpad.diff
new file mode 100644
index 0000000..2062263
--- /dev/null
+++ b/patches/scratchpad.diff
@@ -0,0 +1,90 @@
+diff -up a/config.def.h b/config.def.h
+--- a/config.def.h 2019-06-06 21:23:27.006661784 +0200
++++ b/config.def.h 2019-06-20 15:05:59.083102462 +0200
+@@ -58,11 +58,14 @@ static const Layout layouts[] = {
+ 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 scratchpadname[] = "scratchpad";
++static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
+
+ static Key keys[] = {
+ /* modifier key function argument */
+ { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+ { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
++ { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
+ { MODKEY, XK_b, togglebar, {0} },
+ { MODKEY, XK_j, focusstack, {.i = +1 } },
+ { MODKEY, XK_k, focusstack, {.i = -1 } },
+diff -up a/dwm.c b/dwm.c
+--- a/dwm.c 2019-06-06 21:23:27.023328450 +0200
++++ b/dwm.c 2019-06-20 15:07:01.089767947 +0200
+@@ -213,6 +213,7 @@ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
++static void togglescratch(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+ static void unfocus(Client *c, int setfocus);
+@@ -273,6 +274,8 @@ static Window root, wmcheckwin;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+
++static unsigned int scratchtag = 1 << LENGTH(tags);
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+@@ -1052,6 +1055,14 @@ manage(Window w, XWindowAttributes *wa)
+ && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
+ c->bw = borderpx;
+
++ selmon->tagset[selmon->seltags] &= ~scratchtag;
++ if (!strcmp(c->name, scratchpadname)) {
++ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
++ c->isfloating = True;
++ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
++ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
++ }
++
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+ XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
+@@ -1661,6 +1672,7 @@ spawn(const Arg *arg)
+ {
+ if (arg->v == dmenucmd)
+ dmenumon[0] = '0' + selmon->num;
++ selmon->tagset[selmon->seltags] &= ~scratchtag;
+ if (fork() == 0) {
+ if (dpy)
+ close(ConnectionNumber(dpy));
+@@ -1748,6 +1760,28 @@ togglefloating(const Arg *arg)
+ }
+
+ void
++togglescratch(const Arg *arg)
++{
++ Client *c;
++ unsigned int found = 0;
++
++ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
++ if (found) {
++ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
++ if (newtagset) {
++ selmon->tagset[selmon->seltags] = newtagset;
++ focus(NULL);
++ arrange(selmon);
++ }
++ if (ISVISIBLE(c)) {
++ focus(c);
++ restack(selmon);
++ }
++ } else
++ spawn(arg);
++}
++
++void
+ toggletag(const Arg *arg)
+ {
+ unsigned int newtags;