*nohtml*

config/dwm/config.h

   1 #include <X11/Xresource.h>
   2 
   3 const int borderpx  = 2;
   4 const char *fonts[] = { "Terminus-9" };
   5 
   6 const int topbar   = 1;
   7 const int showbar  = 1;
   8 const char *tags[] = { "www", "dev", "vid", "etc" };
   9 const Layout layouts[] = { // {{{
  10     { "[]=", tile    },
  11     { "><>", NULL    },
  12     { "[M]", monocle }
  13 }; // }}}
  14 
  15 const int snap = 32;
  16 const int nmaster = 1;
  17 const float mfact = 0.55;
  18 const int resizehints = 1;
  19 
  20 char dmenumon[] = "";
  21 char dmenucmd[] = "";
  22 
  23 char background[] = "#000000";
  24 char foreground[] = "#ffffff";
  25 const char *colors[][3] = { // {{{
  26     [SchemeNorm] = { foreground, background, background },
  27     [SchemeSel]  = { background, foreground, foreground }
  28 }; // }}}
  29 
  30 const Rule rules[] = {
  31     { "Wine", NULL, NULL,       0, 1, -1 },
  32     { NULL,   NULL, "Dropdown", 0, 1, -1 }
  33 };
  34 
  35 #define Mod1  Mod1Mask
  36 #define Mod1s Mod1Mask|ShiftMask
  37 
  38 #define Mod4  Mod4Mask
  39 #define Mod4a Mod4Mask|Mod1Mask
  40 #define Mod4s Mod4Mask|ShiftMask
  41 #define Mod4c Mod4Mask|ControlMask
  42 
  43 #define TAG(key, n) \
  44     { Mod4,  key, view,       {.ui = 1 << (n - 1)} }, \
  45     { Mod4s, key, tag,        {.ui = 1 << (n - 1)} }, \
  46     { Mod4c, key, toggleview, {.ui = 1 << (n - 1)} }, \
  47     { Mod4a, key, toggletag,  {.ui = 1 << (n - 1)} }
  48 
  49 void moveclient(const Arg *arg){ // {{{
  50     if (selmon->sel && !selmon->sel->isfloating)
  51         zoom(arg);
  52     else
  53         movemouse(arg);
  54 } // }}}
  55 void togglefullscreen(const Arg *arg){ // {{{
  56     if (selmon->sel) setfullscreen(selmon->sel, !selmon->sel->isfloating);
  57 } // }}}
  58 
  59 Button buttons[] = {
  60     { ClkTagBar, 0, Button1, view,       {0} },
  61     { ClkTagBar, 0, Button3, toggleview, {0} },
  62 
  63     { ClkTagBar, Mod4, Button1, tag,       {0} },
  64     { ClkTagBar, Mod4, Button3, toggletag, {0} },
  65 
  66     { ClkLtSymbol, 0, Button1, setlayout, {.v = &layouts[0]} },
  67     { ClkLtSymbol, 0, Button2, setlayout, {.v = &layouts[1]} },
  68     { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
  69 
  70     { ClkClientWin, Mod4, Button1, moveclient,  {0} },
  71     { ClkClientWin, Mod4, Button2, killclient,  {0} },
  72     { ClkClientWin, Mod4, Button3, resizemouse, {0} }
  73 };
  74 
  75 Key keys[] = {
  76     { Mod4, XK_q,      killclient, {0} },
  77     { Mod4, XK_Return, zoom,       {0} },
  78 
  79     { Mod4,  XK_z, togglefullscreen, {0} },
  80     { Mod4s, XK_z, togglefloating,   {0} },
  81 
  82     { Mod1,  XK_Tab, focusstack, {.i = +1} },
  83     { Mod1s, XK_Tab, focusstack, {.i = -1} },
  84 
  85     { Mod4, XK_Up,    focusstack, {.i = -1} },
  86     { Mod4, XK_Down,  focusstack, {.i = +1} },
  87     { Mod4, XK_Left,  focusstack, {.i = -1} },
  88     { Mod4, XK_Right, focusstack, {.i = +1} },
  89 
  90     { Mod4c, XK_Left,  setmfact, {.f = -0.05} },
  91     { Mod4c, XK_Right, setmfact, {.f = +0.05} },
  92 
  93     { Mod4c, XK_i, incnmaster, {.i = +1} },
  94     { Mod4c, XK_o, incnmaster, {.i = -1} },
  95 
  96     { Mod4c, XK_t, setlayout, {.v = &layouts[0]} },
  97     { Mod4c, XK_m, setlayout, {.v = &layouts[2]} },
  98     { Mod4c, XK_b, togglebar, {0} },
  99 
 100     { Mod4, XK_Tab, view, {0} },
 101     TAG(XK_1, 1),  TAG(XK_2, 2),
 102     TAG(XK_3, 3),  TAG(XK_4, 4)
 103 };
 104 
 105 int sighup = 0;
 106 void signals(int sig){ // {{{
 107     sighup  = sig == SIGHUP;
 108     running = !sighup;
 109 } // }}}
 110 
 111 __attribute__((constructor)) void _main(){ // {{{
 112     void *xres, *xrdb;
 113     char *type; XrmValue value;
 114 
 115     dpy = XOpenDisplay(NULL);
 116     signal(SIGHUP, signals);
 117 
 118     if (
 119         !(xres = XResourceManagerString(dpy)) ||
 120         !(xrdb = XrmGetStringDatabase(xres))
 121     ) goto end;
 122 
 123     XrmGetResource(xrdb, "background", NULL, &type, &value) &&
 124     strcpy(background, value.addr);
 125 
 126     XrmGetResource(xrdb, "foreground", NULL, &type, &value) &&
 127     strcpy(foreground, value.addr);
 128 
 129     end:
 130     XCloseDisplay(dpy);
 131 } // }}}
 132 __attribute__((destructor)) void main_(){ // {{{
 133     if (!sighup) return;
 134 
 135     char *argv[] = { "dwm", NULL };
 136     execvp(argv[0], argv);
 137 } // }}}