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 unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom 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 *fonts[] = { "SauceCodePro Nerd Font Mono:size=20:antialias:true:autohint:true" };
static const char dmenufont[] = "SauceCodePro Nerd Font Mono:size=10:antialias:true:autohint:true";
static const char color_black[] = "#1D2021"; static const char color_black[] = "#1D2021";
static const char color_green[] = "#98971A"; static const char color_green[] = "#98971A";
static const char color_red[] = "#CC241D"; static const char color_red[] = "#CC241D";
@ -56,14 +55,16 @@ static const Layout layouts[] = {
/* commands */ /* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ 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 *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 *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 *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[] = { static Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_p, spawn, {.v = pmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY|ShiftMask, XK_l, spawn, {.v = lockcmd } }, { MODKEY|ShiftMask, XK_l, spawn, {.v = lockcmd } },
{ MODKEY|ShiftMask, XK_m, spawn, {.v = mailcmd } }, { MODKEY|ShiftMask, XK_m, spawn, {.v = mailcmd } },

69
dwm.c
View File

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