summaryrefslogtreecommitdiff
path: root/dwm
diff options
context:
space:
mode:
Diffstat (limited to 'dwm')
-rw-r--r--dwm/Makefile3
-rw-r--r--dwm/config.h9
-rw-r--r--dwm/dwm.c66
3 files changed, 69 insertions, 9 deletions
diff --git a/dwm/Makefile b/dwm/Makefile
index 924ef09..bc6161e 100644
--- a/dwm/Makefile
+++ b/dwm/Makefile
@@ -39,6 +39,8 @@ dist: clean
install: all
mkdir -p ${DESTDIR}${PREFIX}/bin
install -Dm755 ./dwm ${DESTDIR}${PREFIX}/bin
+ cp -f layoutmenu $(DESTDIR)$(PREFIX)/bin
+ chmod 755 $(DESTDIR)$(PREFIX)/bin/layoutmenu
mkdir -p ${DESTDIR}${MANPREFIX}/man1
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
@@ -47,6 +49,7 @@ install: all
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
+ $(DESTDIR)$(PREFIX)/bin/layoutmenu\
${DESTDIR}${PREFIX}/share/dwm/thesiah.mom\
${DESTDIR}${MANPREFIX}/man1/dwm.1
diff --git a/dwm/config.h b/dwm/config.h
index 3098b92..d15cad5 100644
--- a/dwm/config.h
+++ b/dwm/config.h
@@ -23,6 +23,11 @@ static const int allowkill = 1; /* allow killing clients by
static const int vertpad = PADDING; /* vertical padding of bar */
static const int sidepad = PADDING; /* horizontal padding of bar */
static const char *barlayout = "tln|s"; /* t: tag, l: layout, n: name, s: status */
+static const unsigned int ulinepad = 5; /* horizontal padding between the underline and tag */
+static const unsigned int ulinestroke = 2; /* thickness / height of the underline */
+static const unsigned int ulinevoffset = 0; /* how far above the bottom of the bar the line should appear */
+static const int ulineall = 0; /* 1 to show underline on all tags, 0 for just the active ones */
+
static char *fonts[] = {
"monospace:size=10",
"NotoColorEmoji:pixelsize=10:antialias=true:autohint=true" };
@@ -162,6 +167,7 @@ static const Layout layouts[] = {
// normbgcolor, "-nf", normfgcolor, "-sb",
// selbordercolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { TERMINAL, NULL };
+static const char *layoutmenu_cmd = "layoutmenu";
/* Xresources preferences to load at startup */
ResourcePref resources[] = {
@@ -258,6 +264,8 @@ static const Key keys[] = {
{ MODKEY2 | ControlMask, XK_period, exresize, { .v = (int []){ 25, 25 } } },
// LAYOUT SIZES
+ { MODKEY | ShiftMask, XK_h, layoutscroll, { .i = -1 } },
+ { MODKEY | ShiftMask, XK_l, layoutscroll, { .i = +1 } },
{ MODKEY | ShiftMask, XK_n, incnmaster, { .i = -1 } },
{ MODKEY | ControlMask, XK_n, incnmaster, { .i = +1 } },
{ MODKEY, XK_f, togglefullscr, {0} },
@@ -565,6 +573,7 @@ static const Button buttons[] = {
{ ClkClientWin, MODKEY | ShiftMask, Button3, gesture, {0} },
{ ClkClientWin, MODKEY, Button4, incrgaps, { .i = -1 } },
{ ClkClientWin, MODKEY, Button5, incrgaps, { .i = +1 } },
+ { ClkLtSymbol, 0, Button3, layoutmenu, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button2, spawntag, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
diff --git a/dwm/dwm.c b/dwm/dwm.c
index ca04040..a77e841 100644
--- a/dwm/dwm.c
+++ b/dwm/dwm.c
@@ -229,6 +229,7 @@ struct Monitor
Window barwin;
const Layout *lt[2];
Pertag *pertag;
+ int ltcur; /* current layout */
};
typedef struct
@@ -301,6 +302,8 @@ static void keypress(XEvent *e);
static void keypresscmd(XEvent *e);
static void killclient(const Arg *arg);
static void killthis(Client *c);
+static void layoutmenu(const Arg *arg);
+static void layoutscroll(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
@@ -994,6 +997,7 @@ Monitor *createmon(void)
m->gappiv = gappiv;
m->gappoh = gappoh;
m->gappov = gappov;
+ m->ltcur = 0;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@@ -1106,13 +1110,14 @@ drawbar(Monitor *m)
if (moveright)
x -= tw;
if (m->sel) {
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, moveright ? tw : m->ww, bh, lrpad / 2, m->sel->name, 0);
- if (m->sel->isfloating)
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
- } else {
- drw_rect(drw, x, 0, tw, bh, 1, 1);
+ drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
+ drw_text(drw, x, 0, moveright ? tw : m->ww, bh, lrpad / 2, m->sel->name, 0);
+ if (m->sel->isfloating)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
+ } else {
+ drw_rect(drw, x, 0, tw, bh, 1, 1);
}
+
if (!moveright)
x += tw;
break;
@@ -1142,13 +1147,19 @@ drawbar(Monitor *m)
x -= tw;
}
for (j = 0; j < LENGTH(tags); j++) {
- /* do not draw vacant tags */
- if (!(occ & 1 << j || m->tagset[m->seltags] & 1 << j))
- continue;
+ /* do not draw vacant tags */
+ if (!(occ & 1 << j || m->tagset[m->seltags] & 1 << j))
+ continue;
w = TEXTW(tags[j]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << j ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[j], urg & 1 << j);
+ if (keymode == ModeCommand && selmon->tagset[selmon->seltags] & (1 << j)) {
+ drw_rect(drw, x + ulinepad, bh - ulinestroke - ulinevoffset, w - (ulinepad * 2), ulinestroke,
+ m == selmon && selmon->sel && selmon->sel->tags & 1 << j,
+ urg & 1 << j);
+ }
+
x += w;
}
if (moveright)
@@ -1557,6 +1568,42 @@ killthis(Client *c)
}
void
+layoutmenu(const Arg *arg) {
+ FILE *p;
+ char c[3], *s;
+ int i;
+
+ if (!(p = popen(layoutmenu_cmd, "r")))
+ return;
+ s = fgets(c, sizeof(c), p);
+ pclose(p);
+
+ if (!s || *s == '\0' || c[0] == '\0')
+ return;
+
+ i = atoi(c);
+ setlayout(&((Arg) { .v = &layouts[i] }));
+}
+
+void
+layoutscroll(const Arg *arg)
+{
+ if (!arg || !arg->i)
+ return;
+ int switchto = selmon->ltcur + arg->i;
+ int l = LENGTH(layouts);
+
+ if (switchto == l)
+ switchto = 0;
+ else if(switchto < 0)
+ switchto = l - 1;
+
+ selmon->ltcur = switchto;
+ Arg arg2 = {.v= &layouts[switchto] };
+ setlayout(&arg2);
+}
+
+void
manage(Window w, XWindowAttributes *wa)
{
Client *c, *t = NULL, *term = NULL;
@@ -2162,6 +2209,7 @@ setkeymode(const Arg *arg)
return;
keymode = arg->ui;
clearcmd(NULL);
+ updatestatus();
grabkeys();
}