summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2021-03-20 23:17:37 -0500
committerzachir <zachir@librem.one>2021-03-20 23:17:37 -0500
commitdad17ed7e8f24740110d4b64633d0193a84935e0 (patch)
tree159d03f159f7b43e105cbd545d4971f8babe3374
parent83e1c9d0268af712e9f56ab1515d9d21d062f5fb (diff)
Add scratchpads (htop, term, pulsemixer, bluetoothctl, ncmpcpp)
-rw-r--r--config.def.h30
-rw-r--r--config.h125
-rw-r--r--dwm.c43
-rwxr-xr-xdwmc4
4 files changed, 145 insertions, 57 deletions
diff --git a/config.def.h b/config.def.h
index 8bfef3e..9b6eba9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -24,6 +24,19 @@ static const char *colors[][3] = {
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
};
+typedef struct {
+ const char *name;
+ const void *cmd;
+} Sp;
+const char *spcmd1[] = {"st", "-n", "sphtop", "-g", "120x34", NULL };
+const char *spcmd2[] = {"st", "-n", "spst", "-g", "120x34", NULL };
+const char *spcmd3[] = {"st", "-n", "sppm", "-g", "120x34", NULL };
+static Sp scratchpads[] = {
+ {"sphtop", spcmd1},
+ {"spst", spcmd2},
+ {"sppm", spcmd3},
+};
+
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
@@ -33,10 +46,13 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating isterminal noswallow monitor */
- { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
- { "st", NULL, NULL, 0, 0, 1, -1, -1 },
- { NULL, NULL, "Event Tester", 0, 1, 0, 1, -1 }, /* xev */
+ { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
+ { "st", NULL, NULL, 0, 0, 1, -1, -1 },
+ { NULL, NULL, "Event Tester", 0, 1, 0, 1, -1 }, /* xev */
+ { NULL, "sphtop", NULL, SPTAG(0), 1, 1, 1, -1 },
+ { NULL, "spst", NULL, SPTAG(1), 1, 1, 1, -1 },
+ { NULL, "sppm", NULL, SPTAG(2), 1, 1, 1, -1 },
};
/* layout(s) */
@@ -68,6 +84,7 @@ 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 Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
@@ -97,6 +114,9 @@ static Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ { MODKEY, XK_y, togglescratch, {.ui = 0 } },
+ { MODKEY, XK_u, togglescratch, {.ui = 1 } },
+ { MODKEY, XK_x, togglescratch, {.ui = 2 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
@@ -122,7 +142,7 @@ static Button buttons[] = {
{ ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
- { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
+ { ClkClientWin, MODKEY, Button1, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, MODKEY, Button1, tag, {0} },
diff --git a/config.h b/config.h
index 607e67f..a215a73 100644
--- a/config.h
+++ b/config.h
@@ -26,6 +26,23 @@ static const char *colors[][3] = {
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
};
+typedef struct {
+ const char *name;
+ const void *cmd;
+} Sp;
+const char *spcmd1[] = { "st", "-g", "150x50", "-n", "sphtop", "-e", "htop", NULL };
+const char *spcmd2[] = { "st", "-g", "150x50", "-n", "spterm", NULL };
+const char *spcmd3[] = { "st", "-g", "150x50", "-n", "sppm", "-e", "pulsemixer", NULL };
+const char *spcmd4[] = { "st", "-g", "150x50", "-n", "spbt", "-e", "bluetoothctl", NULL };
+const char *spcmd5[] = { "st", "-g", "150x50", "-n", "spncmp", "-e", "ncmpcpp", NULL };
+static Sp scratchpads[] = {
+ { "sphtop", spcmd1 },
+ { "spterm", spcmd2 },
+ { "sppm", spcmd3 },
+ { "spbt", spcmd4 },
+ { "spncmp", spcmd5 },
+};
+
/* tagging */
static const char *tags[] = { " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9" };
@@ -59,6 +76,11 @@ static const Rule rules[] = {
{ NULL, NULL, "steam", 4, 0, 0, 0, -1 },
{ "Lutris", NULL, NULL, 2, 0, 0, 0, -1 },
{ "lutris", NULL, NULL, 2, 0, 0, 0, -1 },
+ { NULL, "sphtop",NULL, SPTAG(0),1, 1, 1, -1 },
+ { NULL, "spterm",NULL, SPTAG(1),1, 1, 1, -1 },
+ { NULL, "sppm", NULL, SPTAG(2),1, 1, 1, -1 },
+ { NULL, "spbt", NULL, SPTAG(3),1, 1, 1, -1 },
+ { NULL, "spncmp",NULL, SPTAG(4),1, 1, 1, -1 },
};
/* layout(s) */
@@ -88,6 +110,7 @@ static const Layout layouts[] = {
/* 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 *rmenucmd[] = { "/usr/sbin/j4-dmenu-desktop", NULL };
static const char *passmenu[] = { "passmenu", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "tabbed", "-c", "st", "-w", NULL };
static const char *mpdtoggle[] = { "playerctl", "--player=mpd,mpv,%any", "play-pause", NULL };
@@ -108,51 +131,57 @@ static const char *xkillcmd[] = { "xkill", NULL };
static Key keys[] = {
/* modifier key function argument */
- { MODKEY, XK_d, spawn, {.v = dmenucmd } },
- { MODKEY, XK_p, spawn, {.v = passmenu } },
- { MODKEY, XK_c, spawn, {.v = xidletog } },
- { MODKEY, XK_x, spawn, {.v = xkillcmd } },
- { MODKEY, XK_Return, spawn, {.v = termcmd } },
- { 0, XF86XK_AudioPlay, spawn, {.v = mpdtoggle } },
- { 0, XF86XK_AudioNext, spawn, {.v = mpdnext } },
- { 0, XF86XK_AudioPrev, spawn, {.v = mpdprev } },
- { ShiftMask, XF86XK_AudioPlay, spawn, {.v = plytoggle } },
- { ShiftMask, XF86XK_AudioNext, spawn, {.v = plyfwd } },
- { ShiftMask, XF86XK_AudioPrev, spawn, {.v = plybck } },
- { 0, XF86XK_MonBrightnessUp, spawn, {.v = blightup } },
- { 0, XF86XK_MonBrightnessDown, spawn, {.v = blightdown } },
- { 0, XF86XK_AudioLowerVolume, spawn, {.v = audiodown } },
- { 0, XF86XK_AudioRaiseVolume, spawn, {.v = audioup } },
- { 0, XF86XK_AudioMute, spawn, {.v = audiomute } },
- { 0, XF86XK_AudioMicMute, spawn, {.v = micmute } },
- { Mod4Mask, XK_l, spawn, {.v = lockscr } },
- { MODKEY, XK_b, togglebar, {0} },
- { MODKEY, XK_j, focusstack, {.i = +1 } },
- { MODKEY, XK_k, focusstack, {.i = -1 } },
- { MODKEY|ShiftMask, XK_j, pushdown, {.i = +1 } },
- { MODKEY|ShiftMask, XK_k, pushup, {.i = -1 } },
- { MODKEY|ControlMask, XK_k, setcfact, {.f = +0.25} },
- { MODKEY|ControlMask, XK_j, setcfact, {.f = -0.25} },
- { MODKEY|ControlMask, XK_o, setcfact, {.f = 0.00} },
- { MODKEY|ShiftMask, XK_h, incnmaster, {.i = +1 } },
- { MODKEY|ShiftMask, XK_l, 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|ShiftMask, XK_q, killclient, {0} },
- { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
- { MODKEY, XK_s, setlayout, {.v = &layouts[1]} },
- { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
- { MODKEY|ShiftMask, XK_space, setlayout, {-1} },
- { MODKEY, XK_space, togglefloating, {0} },
- { MODKEY, XK_f, togglefullscr, {0} },
- { MODKEY, XK_0, view, {.ui = ~0 } },
- { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
- { MODKEY|ControlMask, XK_comma, focusmon, {.i = -1 } },
- { MODKEY|ControlMask, XK_period, focusmon, {.i = +1 } },
- { MODKEY|ControlMask|ShiftMask, XK_comma, tagmon, {.i = -1 } },
- { MODKEY|ControlMask|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ { MODKEY, XK_d, spawn, {.v = dmenucmd } },
+ { MODKEY, XK_r, spawn, {.v = rmenucmd } },
+ { MODKEY, XK_p, spawn, {.v = passmenu } },
+ { MODKEY, XK_c, spawn, {.v = xidletog } },
+ { MODKEY, XK_x, spawn, {.v = xkillcmd } },
+ { MODKEY, XK_Return, spawn, {.v = termcmd } },
+ { MODKEY|ControlMask, XK_z, togglescratch, {.ui = 0 } },
+ { MODKEY|ControlMask, XK_x, togglescratch, {.ui = 1 } },
+ { MODKEY|ControlMask, XK_c, togglescratch, {.ui = 2 } },
+ { MODKEY|ControlMask, XK_v, togglescratch, {.ui = 3 } },
+ { MODKEY|ControlMask, XK_b, togglescratch, {.ui = 4 } },
+ // { 0, XF86XK_AudioPlay, spawn, {.v = mpdtoggle } },
+ // { 0, XF86XK_AudioNext, spawn, {.v = mpdnext } },
+ // { 0, XF86XK_AudioPrev, spawn, {.v = mpdprev } },
+ // { ShiftMask, XF86XK_AudioPlay, spawn, {.v = plytoggle } },
+ // { ShiftMask, XF86XK_AudioNext, spawn, {.v = plyfwd } },
+ // { ShiftMask, XF86XK_AudioPrev, spawn, {.v = plybck } },
+ // { 0, XF86XK_MonBrightnessUp, spawn, {.v = blightup } },
+ // { 0, XF86XK_MonBrightnessDown, spawn, {.v = blightdown } },
+ // { 0, XF86XK_AudioLowerVolume, spawn, {.v = audiodown } },
+ // { 0, XF86XK_AudioRaiseVolume, spawn, {.v = audioup } },
+ // { 0, XF86XK_AudioMute, spawn, {.v = audiomute } },
+ // { 0, XF86XK_AudioMicMute, spawn, {.v = micmute } },
+ // { Mod4Mask, XK_l, spawn, {.v = lockscr } },
+ { MODKEY, XK_b, togglebar, {0} },
+ { MODKEY, XK_j, focusstack, {.i = +1 } },
+ { MODKEY, XK_k, focusstack, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_j, pushdown, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_k, pushup, {.i = -1 } },
+ { MODKEY|ControlMask, XK_k, setcfact, {.f = +0.25} },
+ { MODKEY|ControlMask, XK_j, setcfact, {.f = -0.25} },
+ { MODKEY|ControlMask, XK_o, setcfact, {.f = 0.00} },
+ { MODKEY|ShiftMask, XK_h, incnmaster, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_l, 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|ShiftMask, XK_q, killclient, {0} },
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_s, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ /* { MODKEY|ShiftMask, XK_space, setlayout, {-1} }, */
+ { MODKEY, XK_space, togglefloating, {0} },
+ { MODKEY, XK_f, togglefullscr, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+ { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
+ { MODKEY|ControlMask, XK_comma, focusmon, {.i = -1 } },
+ { MODKEY|ControlMask, XK_period, focusmon, {.i = +1 } },
+ { MODKEY|ControlMask|ShiftMask, XK_comma, tagmon, {.i = -1 } },
+ { MODKEY|ControlMask|ShiftMask, XK_period, tagmon, {.i = +1 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
@@ -162,9 +191,9 @@ static Key keys[] = {
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
- { MODKEY|ShiftMask, XK_e, quit, {0} },
- { MODKEY|ShiftMask, XK_r, quit, {1} },
- { MODKEY|ShiftMask, XK_Tab, toggleAttachBelow, {0} },
+ { MODKEY|ShiftMask, XK_e, quit, {0} },
+ { MODKEY|ShiftMask, XK_r, quit, {1} },
+ { MODKEY|ShiftMask, XK_Tab, toggleAttachBelow, {0} },
};
/* button definitions */
diff --git a/dwm.c b/dwm.c
index cecbe53..5fb86a6 100644
--- a/dwm.c
+++ b/dwm.c
@@ -56,7 +56,10 @@
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
-#define TAGMASK ((1 << LENGTH(tags)) - 1)
+#define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads))
+#define TAGMASK ((1 << NUMTAGS) - 1)
+#define SPTAG(i) ((1 << LENGTH(tags) << (i)))
+#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
#define SYSTEM_TRAY_REQUEST_DOCK 0
@@ -268,6 +271,7 @@ static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscr(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);
@@ -379,6 +383,11 @@ applyrules(Client *c)
c->noswallow = r->noswallow;
c->isfloating = r->isfloating;
c->tags |= r->tags;
+ if ((r->tags & SPTAGMASK) && r->isfloating) {
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
+ }
+
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
@@ -388,7 +397,7 @@ applyrules(Client *c)
XFree(ch.res_class);
if (ch.res_name)
XFree(ch.res_name);
- c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
+ c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
}
int
@@ -2139,6 +2148,10 @@ showhide(Client *c)
if (!c)
return;
if (ISVISIBLE(c)) {
+ if ((c->tags & SPTAGMASK) && c->isfloating) {
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
+ }
/* show clients top down */
XMoveWindow(dpy, c->win, c->x, c->y);
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
@@ -2304,6 +2317,32 @@ togglefullscr(const Arg *arg)
}
void
+togglescratch(const Arg *arg)
+{
+ Client *c;
+ unsigned int found = 0;
+ unsigned int scratchtag = SPTAG(arg->ui);
+ Arg sparg = {.v = scratchpads[arg->ui].cmd};
+
+ 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 {
+ selmon->tagset[selmon->seltags] |= scratchtag;
+ spawn(&sparg);
+ }
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;
diff --git a/dwmc b/dwmc
index 5ff8dbc..2725e5d 100755
--- a/dwmc
+++ b/dwmc
@@ -7,7 +7,7 @@ signal() {
case $# in
1)
case $1 in
- setlayout | view | viewall | togglebar | togglefloating | zoom | killclient | quit)
+ setlayout | view | viewall | togglebar | togglefloating | zoom | killclient)
signal $1
;;
*)
@@ -21,7 +21,7 @@ case $# in
view)
signal $1 ui $2
;;
- viewex | toggleviewex | tagex | toggletagex | setlayoutex | focusstack | incnmaster | focusmon | tagmon)
+ viewex | toggleviewex | tagex | toggletagex | setlayoutex | focusstack | incnmaster | focusmon | tagmon | quit)
signal $1 i $2
;;
setmfact)