aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryson Steck <brysonsteck@protonmail.com>2022-11-13 18:17:50 -0700
committerBryson Steck <brysonsteck@protonmail.com>2022-11-13 18:17:50 -0700
commitc5738de01d3c8adccaf87842cd6efceafd795d98 (patch)
treea4e6eaf064b3881e62e66d16f63aac3adce63896
parent7516b03d7d3c7844ebdab69cf731d59ea2b3c84d (diff)
downloaddwm-c5738de01d3c8adccaf87842cd6efceafd795d98.tar
dwm-c5738de01d3c8adccaf87842cd6efceafd795d98.tar.gz
dwm-c5738de01d3c8adccaf87842cd6efceafd795d98.tar.bz2
sticky patches and exit script
-rw-r--r--config.def.h3
-rw-r--r--config.h9
-rw-r--r--drw.c20
-rw-r--r--drw.h1
-rw-r--r--dwm.c16
5 files changed, 45 insertions, 4 deletions
diff --git a/config.def.h b/config.def.h
index 773262f..54dff0f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -18,6 +18,8 @@ static const char *colors[][3] = {
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
};
+static const XPoint stickyicon[] = { {0,0}, {4,0}, {4,8}, {2,6}, {0,8}, {0,0} }; /* represents the icon as an array of vertices */
+static const XPoint stickyiconbb = {4,8}; /* defines the bottom right corner of the polygon's bounding box (speeds up scaling) */
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
@@ -84,6 +86,7 @@ static Key keys[] = {
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_s, togglesticky, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
diff --git a/config.h b/config.h
index eaee5e4..12f14fd 100644
--- a/config.h
+++ b/config.h
@@ -8,7 +8,7 @@ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const int swallowfloating = 0;
static const char *fonts[] = { "JetBrains Mono NF:style=medium:size=11" };
-static const char dmenufont[] = "JetBrains Mono NF:stlye=medium:size=11";
+static const char dmenufont[] = "JetBrains Mono NF:style=medium:size=11";
// gruvbox
static const char fg[] = "#ebdbb2";
static const char bg_normal[] = "#3c3836";
@@ -27,6 +27,9 @@ static const char *colors[][3] = {
[SchemeSel] = { fg, bg_selected, dr_selected },
};
+static const XPoint stickyicon[] = { {0,0}, {4,0}, {4,8}, {2,6}, {0,8}, {0,0} }; /* represents the icon as an array of vertices */
+static const XPoint stickyiconbb = {4,8}; /* defines the bottom right corner of the polygon's bounding box (speeds up scaling) */
+
/* tagging */
static const char *tags[] = { "!", "@", "#", "$", "%", "^", "&", "*", "(" };
@@ -91,6 +94,7 @@ static const char *playpause[] = { "playerctl", "play-pause", NULL };
static const char *next[] = { "f9.sh", NULL };
static const char *previous[] = { "playerctl", "previous", NULL };
static const char *keepass[] = { "keepassxc", NULL };
+static const char *quitconf[] = { "quitconf", dmenumon, bg_normal, fg, fg, NULL };
static Key keys[] = {
/* modifier key function argument */
@@ -115,6 +119,7 @@ static Key keys[] = {
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_s, togglesticky, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
@@ -142,7 +147,7 @@ static Key keys[] = {
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
- { MODKEY|ShiftMask, XK_BackSpace, quit, {0} },
+ { MODKEY|ShiftMask, XK_BackSpace, spawn, {.v = quitconf} },
};
/* button definitions */
diff --git a/drw.c b/drw.c
index 2feea7e..54602d7 100644
--- a/drw.c
+++ b/drw.c
@@ -249,6 +249,26 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
}
+void
+drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled) /* wrapper function to scale and draw a polygon with X11 */
+{
+ if (!drw || !drw->scheme)
+ return;
+ XSetForeground(drw->dpy, drw->gc, drw->scheme[ColFg].pixel);
+ if (!filled) { /* reduces the scaled width and height by 1 when drawing the outline to compensate for X11 drawing the line 1 pixel over */
+ sw -= 1;
+ sh -= 1;
+ }
+ XPoint scaledpoints[npoints];
+ memcpy(scaledpoints, points, npoints);
+ for (int v = 0; v < npoints; v++)
+ scaledpoints[v] = (XPoint){ .x = points[v].x * sw / ow + x, .y = points[v].y * sh / oh + y };
+ if (filled)
+ XFillPolygon(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, shape, CoordModeOrigin); /* Change shape to 'Convex' or 'Complex' in dwm.c if the shape is not 'Nonconvex' */
+ else
+ XDrawLines(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, CoordModeOrigin);
+}
+
int
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
{
diff --git a/drw.h b/drw.h
index 6471431..19d3743 100644
--- a/drw.h
+++ b/drw.h
@@ -52,6 +52,7 @@ void drw_setscheme(Drw *drw, Clr *scm);
/* Drawing functions */
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
+void drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled);
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
/* Map functions */
diff --git a/dwm.c b/dwm.c
index 19ff3a0..8428fbe 100644
--- a/dwm.c
+++ b/dwm.c
@@ -49,7 +49,7 @@
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
-#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky)
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
@@ -92,7 +92,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
int bw, oldbw;
unsigned int tags;
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, issticky;
int issteam;
Client *next;
Client *snext;
@@ -215,6 +215,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 togglesticky(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
@@ -757,6 +758,8 @@ drawbar(Monitor *m)
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
+ if (m->sel->issticky)
+ drw_polygon(drw, x + boxs, m->sel->isfloating ? boxs * 2 + boxw : boxs, stickyiconbb.x, stickyiconbb.y, boxw, boxw * stickyiconbb.y / stickyiconbb.x, stickyicon, LENGTH(stickyicon), Nonconvex, m->sel->tags & m->tagset[m->seltags]);
} else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
@@ -1757,6 +1760,15 @@ togglefloating(const Arg *arg)
}
void
+togglesticky(const Arg *arg)
+{
+ if (!selmon->sel)
+ return;
+ selmon->sel->issticky = !selmon->sel->issticky;
+ arrange(selmon);
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;