aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd
diff options
context:
space:
mode:
authorNicholas Noll <nnoll523@gmail.com>2020-07-19 09:28:46 -0700
committerNicholas Noll <nnoll523@gmail.com>2020-07-19 09:28:46 -0700
commita576520dce2a34424af67358e98d79a06e736911 (patch)
tree38ede99a3cc90544c9d119e2b49cc865b240391a /sys/cmd
parentd4166afda314d3f3326e9f73659a0b4515f2ae65 (diff)
chore: update
Diffstat (limited to 'sys/cmd')
-rw-r--r--sys/cmd/dwm/config.h3
-rw-r--r--sys/cmd/dwm/dwm.c8
-rw-r--r--sys/cmd/dwm/dwm.h2
-rw-r--r--sys/cmd/dwm/hook.c29
-rw-r--r--sys/cmd/term/x.c2
5 files changed, 43 insertions, 1 deletions
diff --git a/sys/cmd/dwm/config.h b/sys/cmd/dwm/config.h
index e0183b6..6866f80 100644
--- a/sys/cmd/dwm/config.h
+++ b/sys/cmd/dwm/config.h
@@ -60,6 +60,8 @@ static Layout layouts[] = {
static char *menucmd[] = { "menu_run", nil };
static char *termcmd[] = { "term", nil };
static char *webscmd[] = { "qutebrowser", nil };
+static char scratchname[] = "scratchpad";
+static char *scratchcmd[] = { "term", "-t", scratchname, "-g", "120x34", nil };
static char *upvolcmd[] = { "vol", "+5%", nil };
static char *lovolcmd[] = { "vol", "-5%", nil };
static char *novolcmd[] = { "vol", "mute", nil };
@@ -76,6 +78,7 @@ static Key keys[] = {
{ 0, XK_upvol, spawn, {.v = upvolcmd} },
{ 0, XK_lovol, spawn, {.v = lovolcmd} },
{ 0, XK_novol, spawn, {.v = novolcmd} },
+ { MODKEY, XK_s, togglescratch, {.v = scratchcmd} },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_f, togglefocus, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
diff --git a/sys/cmd/dwm/dwm.c b/sys/cmd/dwm/dwm.c
index 87613ec..a6d2bd2 100644
--- a/sys/cmd/dwm/dwm.c
+++ b/sys/cmd/dwm/dwm.c
@@ -536,6 +536,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, scratchname)) {
+ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
+ c->isfloating = 1;
+ 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);
diff --git a/sys/cmd/dwm/dwm.h b/sys/cmd/dwm/dwm.h
index 3f2dd0e..6493093 100644
--- a/sys/cmd/dwm/dwm.h
+++ b/sys/cmd/dwm/dwm.h
@@ -220,6 +220,7 @@ extern int lrpad;
extern int (*xerrorxlib)(Display *, XErrorEvent *);
extern uint numlockmask;
extern void (*handler[LASTEvent]) (XEvent *);
+extern int scratchtag;
extern xcb_connection_t *xcon;
@@ -313,6 +314,7 @@ void tile(Monitor *);
void togglebar(Arg *arg);
void togglefocus(Arg *arg);
void togglefloating(Arg *arg);
+void togglescratch(Arg *arg);
void toggletag(Arg *arg);
void toggleview(Arg *arg);
void unfocus(Client *c, int setfocus);
diff --git a/sys/cmd/dwm/hook.c b/sys/cmd/dwm/hook.c
index 1ad45df..cc96ead 100644
--- a/sys/cmd/dwm/hook.c
+++ b/sys/cmd/dwm/hook.c
@@ -1,5 +1,7 @@
#include "dwm.h"
+int scratchtag = 1 << arrlen(tags);
+
void
focusmon(Arg *arg)
{
@@ -254,6 +256,8 @@ setmfact(Arg *arg)
void
spawn(Arg *arg)
{
+ selmon->tagset[selmon->seltags] &= ~scratchtag;
+
if (fork() == 0) {
if (dpy)
close(ConnectionNumber(dpy));
@@ -307,6 +311,31 @@ togglefloating(Arg *arg)
}
void
+togglescratch(Arg *arg)
+{
+ Client *c;
+ uint f = 0;
+
+ for(c = selmon->clients; c && !(f = (c->tags & scratchtag)); c = c->next)
+ ;
+
+ if(f) {
+ f = selmon->tagset[selmon->seltags] ^ scratchtag;
+ if(f) {
+ selmon->tagset[selmon->seltags] = f;
+ focus(nil);
+ arrange(selmon);
+ }
+ if(ISVISIBLE(c)) {
+ focus(c);
+ restack(selmon);
+ }
+ } else
+ spawn(arg);
+
+}
+
+void
toggletag(Arg *arg)
{
uint newtags;
diff --git a/sys/cmd/term/x.c b/sys/cmd/term/x.c
index 1da23cb..308478f 100644
--- a/sys/cmd/term/x.c
+++ b/sys/cmd/term/x.c
@@ -2031,7 +2031,7 @@ run:
opt_cmd = argv;
if (!opt_title)
- opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0];
+ opt_title = (opt_line || !opt_cmd) ? "term" : opt_cmd[0];
setlocale(LC_CTYPE, "");
XSetLocaleModifiers("");