From b00c66af52f664ddeeb212478a5b57e965e4c954 Mon Sep 17 00:00:00 2001 From: Sascha Paunovic Date: Sat, 21 Apr 2018 18:50:01 +0200 Subject: [PATCH] various fixes --- config.h | 29 ++++++++++++++---------- config.mk | 8 +++---- dwm.c | 51 +++++++++++++++---------------------------- push.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ push.diff | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 182 insertions(+), 48 deletions(-) create mode 100644 push.c create mode 100644 push.diff diff --git a/config.h b/config.h index f0fcdf6..3cd0897 100644 --- a/config.h +++ b/config.h @@ -1,27 +1,28 @@ #include "X11/XF86keysym.h" #include "fibonacci.c" +#include "push.c" /* See LICENSE file for copyright and license details. */ /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ -static const int topbar = 0; /* 0 means bottom bar */ -static const char normbgcolor[] = "#222222"; +static const int topbar = 1; /* 0 means bottom bar */ +static const char normbgcolor[] = "#111111"; static const char normfgcolor[] = "#bbbbbb"; -static const char selbordercolor[] = "#386e5f"; -static const char selbgcolor[] = "#386e5f"; +static const char selbordercolor[] = "#222222"; +static const char selbgcolor[] = "#222222"; static const char selfgcolor[] = "#eeeeee"; static unsigned int baralpha = 0xa0; static unsigned int borderalpha = OPAQUE; static const char normbordercolor[] = "#444444"; -static const char *fonts[] = { "Noto Sans Mono:size=10" }; -static const char dmenufont[] = "Noto Sans Mono:size=10"; +static const char *fonts[] = { "Misc TamzenForPowerline:pixelsize=15" }; +static const char dmenufont[] = "Misc TamzenForPowerline:pixelsize=15"; static const char col_gray1[] = "#222222"; static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; static const char col_gray4[] = "#eeeeee"; -static const char col_cyan[] = "#386e5f"; - static const unsigned int gappx = 6; /* gap pixel between windows */ +static const char col_cyan[] = "#222222"; +static const unsigned int gappx = 6; /* gap pixel between windows */ /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const Rule rules[] = { @@ -42,8 +43,8 @@ static const Layout layouts[] = { { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, - { "[\\]", dwindle }, - { "[/]", spiral }, + { "[\\]", dwindle }, + { "[/]", spiral }, }; /* key definitions */ @@ -62,7 +63,7 @@ static char dmenumon[2] = "0"; /* component of dmenu, 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 *passmenucmd[] = {"passmenu", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *term[] = {"st", NULL }; -static const char *brow[] = {"firefox", NULL }; +static const char *brow[] = {"chromium-browser", NULL }; static const char *play[] = {"mpc", "play", NULL }; static const char *stop[] = {"mpc", "stop", NULL}; static const char *next[] = {"mpc", "next", NULL}; @@ -70,6 +71,8 @@ static const char *prev[] = {"mpc", "prev", NULL}; static const char *togg[] = {"mpc", "toggle", NULL}; static const char *lock[] = {"slock", NULL}; static const char *lokk[] = {"lokk", NULL}; +static const char *lowe[] = {"amixer", "-q", "sset", "Master", "5%-", NULL}; +static const char *rais[] = {"amixer", "-q", "sset", "Master", "5%+", NULL}; static Key keys[] = { /* modifier key function argument */ @@ -83,6 +86,8 @@ static Key keys[] = { { 0, XF86XK_AudioPrev, spawn, {.v = prev } }, { 0, XF86XK_AudioStop, spawn, {.v = stop } }, { 0, XF86XK_AudioPlay, spawn, {.v = togg } }, + { 0, XF86XK_AudioLowerVolume, spawn, {.v = lowe } }, + { 0, XF86XK_AudioRaiseVolume, spawn, {.v = rais } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, @@ -106,6 +111,8 @@ static Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + { MODKEY|ControlMask, XK_j, pushdown, {0} }, + { MODKEY|ControlMask, XK_k, pushup, {0} }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) diff --git a/config.mk b/config.mk index 97190d6..8ec6220 100644 --- a/config.mk +++ b/config.mk @@ -7,8 +7,8 @@ VERSION = 6.1 PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man -X11INC = /usr/X11R6/include -X11LIB = /usr/X11R6/lib +X11INC = /usr/include +X11LIB = /usr/lib # Xinerama, comment if you don't want it XINERAMALIBS = -lXinerama @@ -16,9 +16,9 @@ XINERAMAFLAGS = -DXINERAMA # freetype FREETYPELIBS = -lfontconfig -lXft -#FREETYPEINC = /usr/include/freetype2 +FREETYPEINC = /usr/include/freetype2 # OpenBSD (uncomment) -FREETYPEINC = ${X11INC}/freetype2 +#FREETYPEINC = ${X11INC}/freetype2 # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} diff --git a/dwm.c b/dwm.c index a491276..78dc4e9 100644 --- a/dwm.c +++ b/dwm.c @@ -51,8 +51,8 @@ #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) #define LENGTH(X) (sizeof X / sizeof X[0]) #define MOUSEMASK (BUTTONMASK|PointerMotionMask) -#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx) -#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx) +#define WIDTH(X) ((X)->w + 2 * (X)->bw) +#define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TEXTW(X) (drw_text(drw, 0, 0, 0, 0, (X), 0) + drw->fonts[0]->h) @@ -437,9 +437,15 @@ buttonpress(XEvent *e) } if (ev->window == selmon->barwin) { i = x = 0; - do + unsigned int occ = 0; + for(c = m->clients; c; c = c->next) + occ |= c->tags; + do { + /* do not reserve space for vacant tags */ + if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) + continue; x += TEXTW(tags[i]); - while (ev->x >= x && ++i < LENGTH(tags)); + } while (ev->x >= x && ++i < LENGTH(tags)); if (i < LENGTH(tags)) { click = ClkTagBar; arg.ui = 1 << i; @@ -724,11 +730,14 @@ drawbar(Monitor *m) } x = 0; for (i = 0; i < LENGTH(tags); i++) { + /* do not draw vacant tags */ + if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) + continue; w = TEXTW(tags[i]); drw_setscheme(drw, m->tagset[m->seltags] & 1 << i ? &scheme[SchemeSel] : &scheme[SchemeNorm]); drw_text(drw, x, 0, w, bh, tags[i], urg & 1 << i); drw_rect(drw, x + 1, 1, dx, dx, m == selmon && selmon->sel && selmon->sel->tags & 1 << i, - occ & 1 << i, urg & 1 << i); + 0, urg & 1 << i); x += w; } w = blw = TEXTW(m->ltsymbol); @@ -1300,36 +1309,12 @@ void resizeclient(Client *c, int x, int y, int w, int h) { XWindowChanges wc; - unsigned int n; - unsigned int gapoffset; - unsigned int gapincr; - Client *nbc; + c->oldx = c->x; c->x = wc.x = x; + c->oldy = c->y; c->y = wc.y = y; + c->oldw = c->w; c->w = wc.width = w; + c->oldh = c->h; c->h = wc.height = h; wc.border_width = c->bw; - - /* Get number of clients for the selected monitor */ - for (n = 0, nbc = nexttiled(selmon->clients); nbc; nbc = nexttiled(nbc->next), n++); - - /* Do nothing if layout is floating */ - if (c->isfloating || selmon->lt[selmon->sellt]->arrange == NULL) { - gapincr = gapoffset = 0; - } else { - /* Remove border and gap if layout is monocle or only one client */ - if (selmon->lt[selmon->sellt]->arrange == monocle || n == 1) { - gapoffset = 0; - gapincr = -2 * borderpx; - wc.border_width = 0; - } else { - gapoffset = gappx; - gapincr = 2 * gappx; - } - } - - c->oldx = c->x; c->x = wc.x = x + gapoffset; - c->oldy = c->y; c->y = wc.y = y + gapoffset; - c->oldw = c->w; c->w = wc.width = w - gapincr; - c->oldh = c->h; c->h = wc.height = h - gapincr; - XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); configure(c); XSync(dpy, False); diff --git a/push.c b/push.c new file mode 100644 index 0000000..08fe29b --- /dev/null +++ b/push.c @@ -0,0 +1,67 @@ +Client * +nextc(Client *c, float f) { + if(!f) + return nexttiled(c); + + for(; c && !ISVISIBLE(c); c = c->next); + return c; +} + +static Client * +prevc(Client *c, float f) { + Client *p, *r; + + for(p = selmon->clients, r = NULL; c && p && p != c; p = p->next) + if((f || !p->isfloating) && ISVISIBLE(p)) + r = p; + return r; +} + +static void +pushup(const Arg *arg) { + Client *sel = selmon->sel; + Client *c; + + if(!sel || (sel->isfloating && !arg->f)) + return; + if((c = prevc(sel, arg->f))) { + /* attach before c */ + detach(sel); + sel->next = c; + if(selmon->clients == c) + selmon->clients = sel; + else { + for(c = selmon->clients; c->next != sel->next; c = c->next); + c->next = sel; + } + } else { + /* move to the end */ + for(c = sel; c->next; c = c->next); + detach(sel); + sel->next = NULL; + c->next = sel; + } + focus(sel); + arrange(selmon); +} + +static void +pushdown(const Arg *arg) { + Client *sel = selmon->sel; + Client *c; + + if(!sel || (sel->isfloating && !arg->f)) + return; + if((c = nextc(sel->next, arg->f))) { + /* attach after c */ + detach(sel); + sel->next = c->next; + c->next = sel; + } else { + /* move to the front */ + detach(sel); + attach(sel); + } + focus(sel); + arrange(selmon); +} diff --git a/push.diff b/push.diff new file mode 100644 index 0000000..29256d4 --- /dev/null +++ b/push.diff @@ -0,0 +1,75 @@ +URL: http://dwm.suckless.org/patches/push +pushup and pushdown provide a way to move clients inside the clients list. + +Index: dwm/push.c +=================================================================== +--- /dev/null ++++ dwm/push.c +@@ -0,0 +1,67 @@ ++Client * ++nextc(Client *c, float f) { ++ if(!f) ++ return nexttiled(c); ++ ++ for(; c && !ISVISIBLE(c); c = c->next); ++ return c; ++} ++ ++static Client * ++prevc(Client *c, float f) { ++ Client *p, *r; ++ ++ for(p = selmon->clients, r = NULL; c && p && p != c; p = p->next) ++ if((f || !p->isfloating) && ISVISIBLE(p)) ++ r = p; ++ return r; ++} ++ ++static void ++pushup(const Arg *arg) { ++ Client *sel = selmon->sel; ++ Client *c; ++ ++ if(!sel || (sel->isfloating && !arg->f)) ++ return; ++ if((c = prevc(sel, arg->f))) { ++ /* attach before c */ ++ detach(sel); ++ sel->next = c; ++ if(selmon->clients == c) ++ selmon->clients = sel; ++ else { ++ for(c = selmon->clients; c->next != sel->next; c = c->next); ++ c->next = sel; ++ } ++ } else { ++ /* move to the end */ ++ for(c = sel; c->next; c = c->next); ++ detach(sel); ++ sel->next = NULL; ++ c->next = sel; ++ } ++ focus(sel); ++ arrange(selmon); ++} ++ ++static void ++pushdown(const Arg *arg) { ++ Client *sel = selmon->sel; ++ Client *c; ++ ++ if(!sel || (sel->isfloating && !arg->f)) ++ return; ++ if((c = nextc(sel->next, arg->f))) { ++ /* attach after c */ ++ detach(sel); ++ sel->next = c->next; ++ c->next = sel; ++ } else { ++ /* move to the front */ ++ detach(sel); ++ attach(sel); ++ } ++ focus(sel); ++ arrange(selmon); ++} -- 2.11.4.GIT