Dwm configuration and installation linux - Debian/Ubuntu 3/4

Categories:  linux,
Labels:  OS, bash, install

Overview:

Part 1: Preparation

Part 2: Configuration

Part 3: There are a lot of options

Part 4: Installation


As you can see, there are a lot of options. The default config basically chucks them all in so you can use what you need and ditch what you don’t.
I have found that I don’t need most of the options, so here is my config.h for reference after I took to it with a knife and added a couple of tricks:

/* See LICENSE file for copyright and license details. */

/* appearance */
    static const char font[]            = "7x14";
    static const char normbordercolor[] = "#000000";
    static const char normbgcolor[]     = "#cccccc";
    static const char normfgcolor[]     = "#000000";
    static const char selbordercolor[]  = "#cccccc";
    static const char selbgcolor[]      = "#0066ff";
    static const char selfgcolor[]      = "#ffffff";
    static const unsigned int borderpx  = 1;        /* border pixel of windows */
    static const unsigned int snap      = 32;       /* snap pixel */
    static const Bool showbar           = True;    /* False means no bar */
    static const Bool topbar            = True;     /* False means bottom bar */

Different font; selected window border is white.

    /* tagging */
    static const char *tags[] = { "Here", "There" };

    static const Rule rules[] = {
       /* class          instance     title    tags mask    isfloating   monitor */
       {  NULL,          NULL,        NULL,    0,           False,       -1 },
    };

Two tags, “Here” and “There”; I don’t tend to run many windows at once. No rules as I haven’t found I needed any (but you still need to keep this line in here with ‘NULL’)

1
2
3
4
5
6
7
8
9
    /* layout(s) */
    static const float mfact      = 0.5; /* factor of master area size [0.05..0.95] */
    static const Bool resizehints = False; /* True means respect size hints in tiled resizals */

    static const Layout layouts[] = {
       /* symbol     arrange function */
       { "[ ]",      monocle },    /* first entry is default */
       { "[]=",      tile },
    };

Monocle (fullscreen) mode by default, and if I switch to tiling it’s usually with two windows so I split the screen 50:50
‘resizehints = false’ so terminal windows don’t leave odd gaps around the edges.

/* key definitions */
#define MODKEY Mod1Mask
#define TAGKEYS(KEY,TAG) \
    { MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
    { MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \
    { MODKEY|ShiftMask,             KEY,      tag,            {.ui = 1 << TAG} }, \
    { MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      {.ui = 1 << TAG} },
#include <X11/XF86keysym.h>

/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }

Note the line added in here (‘#include <X11/XF86keysym.h>’) - this means you can refer to your XF86 keys in the next section.

1
2
3
4
5
6
7
8
9
10
11
12
/* commands */
static const char *dmenucmd[]         = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[]          = { "xterm", "-rv", "-fn", font, NULL };
static const char *chromiumcmd[]      = { "chromium-browser", "--proxy-server=172.31.232.250:3128", NULL };
static const char *play[]             = { "mocp", "-G", NULL };
static const char *stop[]             = { "mocp", "-x", NULL };
static const char *prev[]             = { "mocp", "-r", NULL };
static const char *next[]             = { "mocp", "-f", NULL };
static const char *mute[]             = { "amixer", "-q", "set", "Master", "toggle", NULL };
static const char *volumedown[]       = { "amixer", "-q", "set", "Master", "2%-", "unmute", NULL };
static const char *volumeup[]         = { "amixer", "-q", "set", "Master", "2%+", "unmute", NULL };
static const char *eject[]            = { "eject", NULL };

Most apps I run from dmenu, but if you need to use something regularly with command line options, like chromium with a proxy server, you can define it here to call with a keybind.
Also you need to define what command each of your XF86 keys will execute.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    static Key keys[] = {
       /* modifier                key                              function        argument */
       { 0,                       XF86XK_Launch1,                  spawn,          {.v = dmenucmd } },
       { 0,                       XK_F6,                           spawn,          {.v = termcmd } },
       { 0,                       XK_F7,                           spawn,          {.v = chromiumcmd  } },
       { 0,                       XF86XK_AudioPlay,                spawn,          {.v = play}},
       { 0,                       XF86XK_AudioStop,                spawn,          {.v = stop}},
       { 0,                       XF86XK_AudioPrev,                spawn,          {.v = prev}},
       { 0,                       XF86XK_AudioNext,                spawn,          {.v = next}},
       { 0,                       XF86XK_AudioMute,                spawn,          {.v = mute}},
       { 0,                       XF86XK_AudioLowerVolume,         spawn,          {.v = volumedown}},
       { 0,                       XF86XK_AudioRaiseVolume,         spawn,          {.v = volumeup}},
       { 0,                       XF86XK_Eject,                    spawn,          {.v = eject}},
       { MODKEY,                  XK_Tab,                          focusstack,     {.i = +1 } },
       { MODKEY,                  XK_space,                        setlayout,      {0} },
       { MODKEY,                  XK_z,                            zoom,           {0} },
       { MODKEY,                  XK_q,                            killclient,     {0} },
       { MODKEY|ControlMask,      XK_q,                            quit,           {0} },
       TAGKEYS(                   XK_comma,                                        0)
       TAGKEYS(                   XK_period,                                       1)
    };

I’ve tried to stick to keybinds that don’t interfere with other apps, e.g. Alt-p is used to select ‘print’ on a print dialog page, so I’ve avoided that.
The XF86 key “Launch1” for dmenu is actually the Super/Windows key, which I remap in ~/.xinitrc (see near the end of this howto)
Alt-space simply toggles between monocle and tiling modes, as they are the only modes I specified earlier.
Alt-comma and alt-period are for “Here” and “There” tags.

1
2
3
4
5
6
7
8
9
10
static Button buttons[] = {
   /* click                event mask      button          function        argument */
   { ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
   { ClkWinTitle,          0,              Button1,        spawn,          {.v = dmenucmd } },
   { ClkWinTitle,          0,              Button3,        spawn,          {.v = termcmd } },
   { ClkTagBar,            0,              Button1,        view,           {0} },
   { ClkTagBar,            ControlMask,    Button1,        toggleview,     {0} },
   { ClkTagBar,            0,              Button3,        tag,            {0} },
   { ClkTagBar,            ControlMask,    Button3,        toggletag,      {0} },
};

Click on the layout symbol to toggle tiling mode; click the status bar text and dmenu starts; right-click to get a terminal.
Click on a tag name to view it; right-click on a tag name to send a window to that tag.

So that’s mine; go to town, or just try the default first, whatever. When you’re done there, it’s time for…

Social Profiles

This web accept cryptocoin donations
BTC address, LTC, ETH, DASH, Uphold:
Why donations?