Minor changes

This commit is contained in:
Franck STAUFFER 2021-01-16 11:51:28 +01:00
parent 8d1c25841b
commit fe0b3cd2cd
Signed by: franck.stauffer
GPG Key ID: AAF5A94045CEC261
2 changed files with 28 additions and 50 deletions

View File

@ -5,8 +5,7 @@ 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 = 1; /* 0 means bottom bar */
static const char *fonts[] = { "SauceCodePro Nerd Font Mono:size=10:antialias:true:autohint:true" };
static const char dmenufont[] = "SauceCodePro Nerd Font Mono:size=10:antialias:true:autohint:true";
static const char *fonts[] = { "SauceCodePro Nerd Font Mono:size=20:antialias:true:autohint:true" };
static const char color_black[] = "#1D2021";
static const char color_green[] = "#98971A";
static const char color_red[] = "#CC241D";
@ -56,14 +55,16 @@ static const Layout layouts[] = {
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "/usr/bin/dmenu_run", "-m", dmenumon, NULL };
static const char *pmenucmd[] = { "/usr/bin/passmenu", NULL };
static const char *termcmd[] = { "/usr/bin/xterm", NULL };
static const char *lockcmd[] = { "/usr/bin/xsecurelock", NULL };
static const char *lockcmd[] = { "/usr/bin/slock", NULL };
static const char *mailcmd[] = { "/usr/bin/thunderbird", NULL };
static const char *webcmd[] = { "/usr/bin/chromium", NULL };
static const char *webcmd[] = { "/usr/lib/firefox/firefox", NULL };
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_p, spawn, {.v = pmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY|ShiftMask, XK_l, spawn, {.v = lockcmd } },
{ MODKEY|ShiftMask, XK_m, spawn, {.v = mailcmd } },

69
dwm.c
View File

@ -830,7 +830,7 @@ deck(Monitor* m)
if (n > m->nmaster) {
mw = m->nmaster ? m->ww * m->mfact : 0;
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
// snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
} else
mw = m->ww;
for (i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
@ -851,10 +851,10 @@ deck(Monitor* m)
void
destroynotify(XEvent* e)
{
Client* c;
XDestroyWindowEvent* ev = &e->xdestroywindow;
Client* c = wintoclient(ev->window);
if ((c = wintoclient(ev->window)))
if (c)
unmanage(c, 1);
}
@ -959,9 +959,7 @@ drawbar(Monitor* m)
void
drawbars(void)
{
Monitor* m;
for (m = mons; m; m = m->next)
for (Monitor* m = mons; m; m = m->next)
drawbar(m);
}
@ -1389,8 +1387,8 @@ monocle(Monitor* m)
for (c = m->clients; c; c = c->next)
if (ISVISIBLE(c))
n++;
if (n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
// if (n > 0) [> override layout symbol <]
// snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
}
@ -1852,11 +1850,9 @@ setlayout(const Arg* arg)
void
setmfact(const Arg* arg)
{
float f;
if (!arg || !selmon->lt[selmon->sellt]->arrange)
return;
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
const float f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if (f < 0.05 || f > 0.95)
return;
selmon->mfact = f;
@ -1962,10 +1958,9 @@ setup(void)
void
seturgent(Client* c, int urg)
{
XWMHints* wmh;
c->isurgent = urg;
if (!(wmh = XGetWMHints(dpy, c->win)))
XWMHints* wmh = XGetWMHints(dpy, c->win);
if (!wmh)
return;
wmh->flags =
urg ? (wmh->flags | XUrgencyHint) : (wmh->flags & ~XUrgencyHint);
@ -2083,9 +2078,7 @@ togglebar(const Arg* arg)
void
togglefloating(const Arg* arg)
{
if (!selmon->sel)
return;
if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
if (!selmon->sel || selmon->sel->isfullscreen)
return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
if (selmon->sel->isfloating)
@ -2174,10 +2167,10 @@ unmanage(Client* c, int destroyed)
void
unmapnotify(XEvent* e)
{
Client* c;
XUnmapEvent* ev = &e->xunmap;
Client* c = wintoclient(ev->window);
if ((c = wintoclient(ev->window))) {
if (c) {
if (ev->send_event)
setclientstate(c, WithdrawnState);
else
@ -2231,12 +2224,9 @@ updatebarpos(Monitor* m)
void
updateclientlist()
{
Client* c;
Monitor* m;
XDeleteProperty(dpy, root, netatom[NetClientList]);
for (m = mons; m; m = m->next)
for (c = m->clients; c; c = c->next)
for (Monitor* m = mons; m; m = m->next)
for (Client* c = m->clients; c; c = c->next)
XChangeProperty(dpy,
root,
netatom[NetClientList],
@ -2330,13 +2320,10 @@ updategeom(void)
void
updatenumlockmask(void)
{
unsigned int i, j;
XModifierKeymap* modmap;
numlockmask = 0;
modmap = XGetModifierMapping(dpy);
for (i = 0; i < 8; i++)
for (j = 0; j < modmap->max_keypermod; j++)
XModifierKeymap* modmap = XGetModifierMapping(dpy);
for (register unsigned int i = 0; i < 8; i++)
for (register unsigned int j = 0; j < modmap->max_keypermod; j++)
if (modmap->modifiermap[i * modmap->max_keypermod + j] ==
XKeysymToKeycode(dpy, XK_Num_Lock))
numlockmask = (1 << i);
@ -2407,21 +2394,18 @@ updatetitle(Client* c)
void
updatewindowtype(Client* c)
{
Atom state = getatomprop(c, netatom[NetWMState]);
Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
if (state == netatom[NetWMFullscreen])
if (getatomprop(c, netatom[NetWMState]) == netatom[NetWMFullscreen])
setfullscreen(c, 1);
if (wtype == netatom[NetWMWindowTypeDialog])
if (getatomprop(c, netatom[NetWMWindowType]) == netatom[NetWMWindowTypeDialog])
c->isfloating = 1;
}
void
updatewmhints(Client* c)
{
XWMHints* wmh;
XWMHints* wmh = XGetWMHints(dpy, c->win);
if ((wmh = XGetWMHints(dpy, c->win))) {
if (wmh) {
if (c == selmon->sel && wmh->flags & XUrgencyHint) {
wmh->flags &= ~XUrgencyHint;
XSetWMHints(dpy, c->win, wmh);
@ -2450,11 +2434,8 @@ view(const Arg* arg)
Client*
wintoclient(Window w)
{
Client* c;
Monitor* m;
for (m = mons; m; m = m->next)
for (c = m->clients; c; c = c->next)
for (Monitor* m = mons; m; m = m->next)
for (Client* c = m->clients; c; c = c->next)
if (c->win == w)
return c;
return NULL;
@ -2533,10 +2514,6 @@ zoom(const Arg* arg)
int
main(int argc, char* argv[])
{
if (argc == 2 && !strcmp("-v", argv[1]))
die("dwm-" VERSION);
else if (argc != 1)
die("usage: dwm [-v]");
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fputs("warning: no locale support\n", stderr);
if (!(dpy = XOpenDisplay(NULL)))