[wiki] [sites] Add patch to customize dwm through command line || Platon Ryzhikov

From: <git_AT_suckless.org>
Date: Fri, 04 May 2018 16:21:29 +0200

commit 3a09feb9d2549e4cbb548bfe6e71d3e97ba0a2c4
Author: Platon Ryzhikov <ihummer63_AT_yandex.ru>
Date: Fri May 4 17:20:19 2018 +0300

    Add patch to customize dwm through command line

diff --git a/dwm.suckless.org/patches/cmdcustomize/dwm-cmdcustomize-20180504-3bd8466.diff b/dwm.suckless.org/patches/cmdcustomize/dwm-cmdcustomize-20180504-3bd8466.diff
new file mode 100644
index 00000000..1a451518
--- /dev/null
+++ b/dwm.suckless.org/patches/cmdcustomize/dwm-cmdcustomize-20180504-3bd8466.diff
_AT_@ -0,0 +1,139 @@
+diff --git a/dwm.1 b/dwm.1
+index e3b2c38..76011c7 100644
+--- a/dwm.1
++++ b/dwm.1
+_AT_@ -3,7 +3,27 @@
+ dwm \- dynamic window manager
+ .SH SYNOPSIS
+ .B dwm
+-.RB [ \-v ]
++.RB [ \-vh ]
++.RB [ \-fn
++.IR font ]
++.RB [ \-nb
++.IR color ]
++.RB [ \-nf
++.IR color ]
++.RB [ \-sb
++.IR color ]
++.RB [ \-sf
++.IR color ]
++.RB [ \-df
++.IR font ]
++.RB [ \-dnb
++.IR color ]
++.RB [ \-dnf
++.IR color ]
++.RB [ \-dsb
++.IR color ]
++.RB [ \-dsf
++.IR color ]
+ .SH DESCRIPTION
+ dwm is a dynamic window manager for X. It manages windows in tiled, monocle
+ and floating layouts. Either layout can be applied dynamically, optimising the
+_AT_@ -34,6 +54,43 @@ dwm draws a small border around windows to indicate the focus state.
+ .TP
+ .B \-v
+ prints version information to standard output, then exits.
++.TP
++.B \-h --help
++prints short help
++.TP
++.BI \-fn " font"
++defines the font or font set used.
++.TP
++.BI \-nb " color"
++defines the normal background color.
++.IR #RGB ,
++.IR #RRGGBB ,
++and X color names are supported.
++.TP
++.BI \-nf " color"
++defines the normal foreground color.
++.TP
++.BI \-sb " color"
++defines the selected background color.
++.TP
++.BI \-sf " color"
++defines the selected foreground color.
++.TP
++.BI \-df " font"
++defines the font used in dmenu_run.
++.TP
++.BI \-dnb " color"
++defines the normal background color in dmenu_run.
++.TP
++.BI \-dnf " color"
++defines the normal foreground color in dmenu_run.
++.TP
++.BI \-dsb " color"
++defines the selected background color in dmenu_run.
++.TP
++.BI \-dsf " color"
++defines the selected foreground color in dmenu_run.
++.TP
+ .SH USAGE
+ .SS Status bar
+ .TP
+diff --git a/dwm.c b/dwm.c
+index c98678d..dc1a679 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -174,6 +174,7 @@ static long getstate(Window w);
+ static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
+ static void grabbuttons(Client *c, int focused);
+ static void grabkeys(void);
++static char* help();
+ static void incnmaster(const Arg *arg);
+ static void keypress(XEvent *e);
+ static void killclient(const Arg *arg);
+_AT_@ -963,6 +964,12 @@ grabkeys(void)
+ }
+ }
+
++char*
++help(void)
++{
++ return "usage: dwm [-hv] [-fn font] [-nb color] [-nf color] [-sb color] [-sf color]
[-df font] [-dnf color] [-dnb color] [-dsf color] [-dsb color]
";
++}
++
+ void
+ incnmaster(const Arg *arg)
+ {
+_AT_@ -2127,10 +2134,32 @@ 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]");
++ for(int i=1;i<argc;i+=1)
++ if (!strcmp("-v", argv[i]))
++ die("dwm-"VERSION);
++ else if (!strcmp("-h", argv[i]) || !strcmp("--help", argv[i]))
++ die(help());
++ else if (!strcmp("-fn", argv[i])) /* font set */
++ fonts[0] = argv[++i];
++ else if (!strcmp("-nb",argv[i])) /* normal background color */
++ colors[SchemeNorm][1] = argv[++i];
++ else if (!strcmp("-nf",argv[i])) /* normal foreground color */
++ colors[SchemeNorm][0] = argv[++i];
++ else if (!strcmp("-sb",argv[i])) /* selected background color */
++ colors[SchemeSel][1] = argv[++i];
++ else if (!strcmp("-sf",argv[i])) /* selected foreground color */
++ colors[SchemeSel][0] = argv[++i];
++ else if (!strcmp("-df", argv[i])) /* dmenu font */
++ dmenucmd[4] = argv[++i];
++ else if (!strcmp("-dnb",argv[i])) /* dmenu normal background color */
++ dmenucmd[6] = argv[++i];
++ else if (!strcmp("-dnf",argv[i])) /* dmenu normal foreground color */
++ dmenucmd[8] = argv[++i];
++ else if (!strcmp("-dsb",argv[i])) /* dmenu selected background color */
++ dmenucmd[10] = argv[++i];
++ else if (!strcmp("-dsf",argv[i])) /* dmenu selected foreground color */
++ dmenucmd[12] = argv[++i];
++ else die(help());
+ if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
+ fputs("warning: no locale support
", stderr);
+ if (!(dpy = XOpenDisplay(NULL)))
diff --git a/dwm.suckless.org/patches/cmdcustomize/index.md b/dwm.suckless.org/patches/cmdcustomize/index.md
new file mode 100644
index 00000000..5118e186
--- /dev/null
+++ b/dwm.suckless.org/patches/cmdcustomize/index.md
_AT_@ -0,0 +1,28 @@
+customise dwm through command line
+==================================
+
+Description
+-----------
+
+Rebuilding dwm to change font or color can become annoying. This patch solves this problem allowing to set these parameters through command line
+New command line options look like the same in dmenu:
+-fn dwm font
+-df dmenu font
+-nb normal background color
+-nf normal foreground color
+-sb selected background color
+-sf selected foreground color
+-dnb normal background color in dmenu
+-dnf normal foreground color in dmenu
+-dsb selected background color in dmenu
+-dsf selected foreground color in dmenu
+
+Download
+--------
+
+* [dwm-cmdcustomize-20180504-3bd8466.diff](dwm-cmdcustomize-20180504-3bd8466.diff)
+
+Author
+------
+
+* Platon Ryzhikov - <ihummer63_AT_yandex.ru>
Received on Fri May 04 2018 - 16:21:29 CEST

This archive was generated by hypermail 2.3.0 : Fri May 04 2018 - 16:24:22 CEST