sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-cmdcustomize-20180504-3bd8466.diff (3791B)


      1 diff --git a/dwm.1 b/dwm.1
      2 index e3b2c38..76011c7 100644
      3 --- a/dwm.1
      4 +++ b/dwm.1
      5 @@ -3,7 +3,27 @@
      6  dwm \- dynamic window manager
      7  .SH SYNOPSIS
      8  .B dwm
      9 -.RB [ \-v ]
     10 +.RB [ \-vh ]
     11 +.RB [ \-fn
     12 +.IR font ]
     13 +.RB [ \-nb
     14 +.IR color ]
     15 +.RB [ \-nf
     16 +.IR color ]
     17 +.RB [ \-sb
     18 +.IR color ]
     19 +.RB [ \-sf
     20 +.IR color ]
     21 +.RB [ \-df
     22 +.IR font ]
     23 +.RB [ \-dnb
     24 +.IR color ]
     25 +.RB [ \-dnf
     26 +.IR color ]
     27 +.RB [ \-dsb
     28 +.IR color ]
     29 +.RB [ \-dsf
     30 +.IR color ]
     31  .SH DESCRIPTION
     32  dwm is a dynamic window manager for X. It manages windows in tiled, monocle
     33  and floating layouts. Either layout can be applied dynamically, optimising the
     34 @@ -34,6 +54,43 @@ dwm draws a small border around windows to indicate the focus state.
     35  .TP
     36  .B \-v
     37  prints version information to standard output, then exits.
     38 +.TP
     39 +.B \-h --help
     40 +prints short help
     41 +.TP
     42 +.BI \-fn " font"
     43 +defines the font or font set used.
     44 +.TP
     45 +.BI \-nb " color"
     46 +defines the normal background color.
     47 +.IR #RGB ,
     48 +.IR #RRGGBB ,
     49 +and X color names are supported.
     50 +.TP
     51 +.BI \-nf " color"
     52 +defines the normal foreground color.
     53 +.TP
     54 +.BI \-sb " color"
     55 +defines the selected background color.
     56 +.TP
     57 +.BI \-sf " color"
     58 +defines the selected foreground color.
     59 +.TP
     60 +.BI \-df " font"
     61 +defines the font used in dmenu_run.
     62 +.TP
     63 +.BI \-dnb " color"
     64 +defines the normal background color in dmenu_run.
     65 +.TP
     66 +.BI \-dnf " color"
     67 +defines the normal foreground color in dmenu_run.
     68 +.TP
     69 +.BI \-dsb " color"
     70 +defines the selected background color in dmenu_run.
     71 +.TP
     72 +.BI \-dsf " color"
     73 +defines the selected foreground color in dmenu_run.
     74 +.TP
     75  .SH USAGE
     76  .SS Status bar
     77  .TP
     78 diff --git a/dwm.c b/dwm.c
     79 index c98678d..dc1a679 100644
     80 --- a/dwm.c
     81 +++ b/dwm.c
     82 @@ -174,6 +174,7 @@ static long getstate(Window w);
     83  static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
     84  static void grabbuttons(Client *c, int focused);
     85  static void grabkeys(void);
     86 +static char* help();
     87  static void incnmaster(const Arg *arg);
     88  static void keypress(XEvent *e);
     89  static void killclient(const Arg *arg);
     90 @@ -963,6 +964,12 @@ grabkeys(void)
     91  	}
     92  }
     93  
     94 +char*
     95 +help(void)
     96 +{
     97 +	return "usage: dwm [-hv] [-fn font] [-nb color] [-nf color] [-sb color] [-sf color]\n[-df font] [-dnf color] [-dnb color] [-dsf color] [-dsb color]\n";
     98 +}
     99 +
    100  void
    101  incnmaster(const Arg *arg)
    102  {
    103 @@ -2127,10 +2134,32 @@ zoom(const Arg *arg)
    104  int
    105  main(int argc, char *argv[])
    106  {
    107 -	if (argc == 2 && !strcmp("-v", argv[1]))
    108 -		die("dwm-"VERSION);
    109 -	else if (argc != 1)
    110 -		die("usage: dwm [-v]");
    111 +	for(int i=1;i<argc;i+=1)
    112 +		if (!strcmp("-v", argv[i]))
    113 +			die("dwm-"VERSION);
    114 +		else if (!strcmp("-h", argv[i]) || !strcmp("--help", argv[i]))
    115 +			die(help());
    116 +		else if (!strcmp("-fn", argv[i])) /* font set */
    117 +			fonts[0] = argv[++i];
    118 +		else if (!strcmp("-nb",argv[i])) /* normal background color */
    119 +			colors[SchemeNorm][1] = argv[++i];
    120 +		else if (!strcmp("-nf",argv[i])) /* normal foreground color */
    121 +			colors[SchemeNorm][0] = argv[++i];
    122 +		else if (!strcmp("-sb",argv[i])) /* selected background color */
    123 +			colors[SchemeSel][1] = argv[++i];
    124 +		else if (!strcmp("-sf",argv[i])) /* selected foreground color */
    125 +			colors[SchemeSel][0] = argv[++i];
    126 +		else if (!strcmp("-df", argv[i])) /* dmenu font */
    127 +			dmenucmd[4] = argv[++i];
    128 +		else if (!strcmp("-dnb",argv[i])) /* dmenu normal background color */
    129 +			dmenucmd[6] = argv[++i];
    130 +		else if (!strcmp("-dnf",argv[i])) /* dmenu normal foreground color */
    131 +			dmenucmd[8] = argv[++i];
    132 +		else if (!strcmp("-dsb",argv[i])) /* dmenu selected background color */
    133 +			dmenucmd[10] = argv[++i];
    134 +		else if (!strcmp("-dsf",argv[i])) /* dmenu selected foreground color */
    135 +			dmenucmd[12] = argv[++i];
    136 +		else die(help());
    137  	if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
    138  		fputs("warning: no locale support\n", stderr);
    139  	if (!(dpy = XOpenDisplay(NULL)))