*nohtml*

config/dwm/config.h

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