*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[] = "#000000";
  19 char foreground[] = "#ffffff";
  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     { NULL,   NULL, "Dropdown", 0, 1, -1 }
  34 };
  35 
  36 #define Mod1 Mod1Mask
  37 #define Mod1Shft Mod1Mask|ShiftMask
  38 
  39 #define Mod4 Mod4Mask
  40 #define Mod4Shft Mod4Mask|ShiftMask
  41 #define Mod4Ctrl Mod4Mask|ControlMask
  42 
  43 #define TAG(key, n) \
  44     { Mod4,     key, view,       {.ui = 1 << n} }, \
  45     { Mod4Shft, key, tag,        {.ui = 1 << n} }, \
  46     { Mod4Ctrl, key, toggleview, {.ui = 1 << n} }
  47 
  48 void togglefullscreen(Arg *arg){
  49     if (selmon->sel) setfullscreen(selmon->sel, !selmon->sel->isfloating);
  50 }
  51 
  52 Button buttons[] = {
  53     { ClkTagBar, 0, Button1, view,       {0} },
  54     { ClkTagBar, 0, Button3, toggleview, {0} },
  55 
  56     { ClkTagBar, Mod4, Button1, tag,       {0} },
  57     { ClkTagBar, Mod4, Button3, toggletag, {0} },
  58 
  59     { ClkLtSymbol, 0, Button1, setlayout, {.v = &layouts[0]} },
  60     { ClkLtSymbol, 0, Button2, setlayout, {.v = &layouts[1]} },
  61     { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
  62 
  63     { ClkClientWin, Mod4, Button1, movemouse,   {0} },
  64     { ClkClientWin, Mod4, Button3, resizemouse, {0} }
  65 };
  66 
  67 Key keys[] = {
  68     { Mod4, XK_q,      killclient, {0} },
  69     { Mod4, XK_Return, zoom,       {0} },
  70 
  71     { Mod4,     XK_z, togglefullscreen, {0} },
  72     { Mod4Shft, XK_z, togglefloating,   {0} },
  73 
  74     { Mod1,     XK_Tab, focusstack, {.i = +1} },
  75     { Mod1Shft, XK_Tab, focusstack, {.i = -1} },
  76 
  77     { Mod4, XK_Up,    focusstack, {.i = -1} },
  78     { Mod4, XK_Down,  focusstack, {.i = +1} },
  79     { Mod4, XK_Left,  focusstack, {.i = -1} },
  80     { Mod4, XK_Right, focusstack, {.i = +1} },
  81 
  82     { Mod4Ctrl, XK_Left,  setmfact, {.f = -0.05} },
  83     { Mod4Ctrl, XK_Right, setmfact, {.f = +0.05} },
  84 
  85     { Mod4Ctrl, XK_i, incnmaster, {.i = +1} },
  86     { Mod4Ctrl, XK_o, incnmaster, {.i = -1} },
  87 
  88     { Mod4Ctrl, XK_t, setlayout,  {.v = &layouts[0]} },
  89     { Mod4Ctrl, XK_m, setlayout,  {.v = &layouts[2]} },
  90     { Mod4Ctrl, XK_b, togglebar,  {0} },
  91 
  92     { Mod4, XK_Tab, view, {0} },
  93     TAG(XK_1, 0),  TAG(XK_2, 1),
  94     TAG(XK_3, 2),  TAG(XK_4, 3)
  95 };
  96 
  97 int sighup = 0;
  98 
  99 void signals(int sig){
 100     sighup  = sig == SIGHUP;
 101     running = !sighup;
 102 }
 103 
 104 __attribute__((constructor)) void _main(){
 105     void *xres, *xrdb;
 106     char *type; XrmValue value;
 107 
 108     dpy = XOpenDisplay(NULL);
 109     signal(SIGHUP, signals);
 110 
 111     if ((xres = XResourceManagerString(dpy)) && (xrdb = XrmGetStringDatabase(xres))){
 112         if (XrmGetResource(xrdb, "background", NULL, &type, &value) == True)
 113             strcpy(background, value.addr);
 114 
 115         if (XrmGetResource(xrdb, "foreground", NULL, &type, &value) == True)
 116             strcpy(foreground, value.addr);
 117     }
 118 
 119     XCloseDisplay(dpy);
 120 }
 121 
 122 __attribute__((destructor)) void main_(){
 123     if (!sighup) return;
 124 
 125     char *argv[] = { "dwm", NULL };
 126     execvp(argv[0], argv);
 127 }