diff --git a/.gitignore b/.gitignore index c65e447..773ae2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .vscode/ *.o -dwm -config.h \ No newline at end of file +dwm \ No newline at end of file diff --git a/LICENSE b/LICENSE index d221f09..f1b48f9 100644 --- a/LICENSE +++ b/LICENSE @@ -17,6 +17,7 @@ MIT/X Consortium License © 2015-2016 Quentin Rameau © 2015-2016 Eric Pruitt © 2016-2017 Markus Teich +© 2020 Sravan Balaji Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/README b/README.md similarity index 84% rename from README rename to README.md index 95d4fd0..fa3eb96 100644 --- a/README +++ b/README.md @@ -1,15 +1,16 @@ -dwm - dynamic window manager -============================ +# Sravan's dwm - dynamic window manager + dwm is an extremely fast, small, and dynamic window manager for X. +This is Sravan's fork of dwm with patches and custom modifications. -Requirements ------------- +## Requirements + In order to build dwm you need the Xlib header files. -Installation ------------- +## Installation + Edit config.mk to match your local setup (dwm is installed into the /usr/local namespace by default). @@ -18,9 +19,8 @@ necessary as root): make clean install +## Running dwm -Running dwm ------------ Add the following line to your .xinitrc to start dwm using startx: exec dwm @@ -42,7 +42,7 @@ like this in your .xinitrc: exec dwm -Configuration -------------- +## Configuration + The configuration of dwm is done by creating a custom config.h and (re)compiling the source code. diff --git a/autostart.sh b/autostart_blocking.sh old mode 100644 new mode 100755 similarity index 100% rename from autostart.sh rename to autostart_blocking.sh diff --git a/config.def.h b/config.def.h index a318520..1c0b587 100644 --- a/config.def.h +++ b/config.def.h @@ -1,17 +1,17 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ -static const unsigned int borderpx = 2; /* border pixel of windows */ +static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "monospace:size=12", "fontawesome:size=12" }; -static const char dmenufont[] = "monospace:size=12"; -static const char col_gray1[] = "#282a36"; /* background color */ -static const char col_gray2[] = "#6272a4"; /* inactive window border color */ -static const char col_gray3[] = "#f8f8f2"; /* font color */ -static const char col_gray4[] = "#282a36"; /* current tag and current window font color */ -static const char col_cyan[] = "#bd93f9"; /* Top bar second color and active window border color */ +static const char *fonts[] = { "monospace:size=10" }; +static const char dmenufont[] = "monospace:size=10"; +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; +static const char col_cyan[] = "#005577"; static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, @@ -19,7 +19,7 @@ static const char *colors[][3] = { }; /* tagging */ -static const char *tags[] = { "", "", "", "", "", "", "", "", "" }; +static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const Rule rules[] = { /* xprop(1): @@ -44,7 +44,7 @@ static const Layout layouts[] = { }; /* key definitions */ -#define MODKEY Mod4Mask /* Mod1Mask = Alt, Mod4Mask = Super */ +#define MODKEY Mod1Mask #define TAGKEYS(KEY,TAG) \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ @@ -57,7 +57,7 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *termcmd[] = { "alacritty", NULL }; +static const char *termcmd[] = { "st", NULL }; static Key keys[] = { /* modifier key function argument */ diff --git a/config.h b/config.h new file mode 100644 index 0000000..41781eb --- /dev/null +++ b/config.h @@ -0,0 +1,117 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const unsigned int borderpx = 2; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ +static const int showbar = 1; /* 0 means no bar */ +static const int topbar = 1; /* 0 means bottom bar */ +static const char *fonts[] = { "monospace:size=12", "fontawesome:size=12" }; +static const char dmenufont[] = "monospace:size=12"; +static const char col_gray1[] = "#282a36"; /* background color */ +static const char col_gray2[] = "#6272a4"; /* inactive window border color */ +static const char col_gray3[] = "#f8f8f2"; /* font color */ +static const char col_gray4[] = "#282a36"; /* current tag and current window font color */ +static const char col_cyan[] = "#bd93f9"; /* Top bar second color and active window border color */ +static const char *colors[][3] = { + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, +}; + +/* tagging */ +static const char *tags[] = { "", "", "", "", "", "", "", "", "" }; + +static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ + /* class instance title tags mask isfloating monitor */ + { "Gimp", NULL, NULL, 0, 1, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, +}; + +/* layout(s) */ +static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const int nmaster = 1; /* number of clients in master area */ +static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ + +static const Layout layouts[] = { + /* symbol arrange function */ + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, +}; + +/* key definitions */ +#define MODKEY Mod4Mask /* Mod1Mask = Alt, Mod4Mask = Super */ +#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} }, + +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + +/* commands */ +static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *termcmd[] = { "alacritty", NULL }; + +static Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_q, quit, {0} }, +}; + +/* button definitions */ +/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +static Button buttons[] = { + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + { ClkTagBar, 0, Button1, view, {0} }, + { ClkTagBar, 0, Button3, toggleview, {0} }, + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, +}; + +/* configuration parameters */ +static const char rootdir[] = "/home/sravan/.config"; /* Location of dwm source code */ diff --git a/dwm.1 b/dwm.1 index d9d258f..06b7807 100644 --- a/dwm.1 +++ b/dwm.1 @@ -162,11 +162,7 @@ Toggles focused window between floating and tiled state. Resize focused window while dragging. Tiled windows will be toggled to the floating state. .SH FILES The files containing programs to be started along with dwm are searched for in -the following directories: -.IP "1. $XDG_DATA_HOME/dwm" -.IP "2. $XDG_CONFIG_HOME/dwm" -.IP "3. $HOME/.local/share/dwm" -.IP "4. $HOME/.dwm" +the dwm root directory. .P The first existing directory is scanned for any of the autostart files below. .TP 15 diff --git a/dwm.c b/dwm.c index 9db00e5..5a8d292 100644 --- a/dwm.c +++ b/dwm.c @@ -242,7 +242,6 @@ static const char autostartblocksh[] = "autostart_blocking.sh"; static const char autostartsh[] = "autostart.sh"; static const char broken[] = "broken"; static const char dwmdir[] = "dwm"; -static const char localshare[] = ".local/share"; static char stext[256]; static int screen; static int sw, sh; /* X display screen geometry width, height */ @@ -1392,43 +1391,13 @@ runautostart(void) { char *pathpfx; char *path; - char *xdgdatahome; - char *xdgconfighome; - char *home; struct stat sb; - if ((home = getenv("HOME")) == NULL) - /* this is almost impossible */ - return; - - /* if $XDG_DATA_HOME is set and not empty, use $XDG_DATA_HOME/dwm, - * otherwise use $XDG_CONFIG_HOME if it is set and not empty, - * otherwise use ~/.local/share/dwm as autostart script directory - */ - xdgdatahome = getenv("XDG_DATA_HOME"); - xdgconfighome = getenv("XDG_CONFIG_HOME"); - if (xdgdatahome != NULL && *xdgdatahome != '\0') { + if (dwmdir != NULL && *dwmdir != '\0') { /* space for path segments, separators and nul */ - pathpfx = ecalloc(1, strlen(xdgdatahome) + strlen(dwmdir) + 2); + pathpfx = ecalloc(1, strlen(rootdir) + strlen(dwmdir) + 2); - if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) { - free(pathpfx); - return; - } - } else if (xdgconfighome != NULL && *xdgdatahome != '\0') { - /* space for path segments, separators and nul */ - pathpfx = ecalloc(1, strlen(xdgconfighome) + strlen(dwmdir) + 2); - - if (sprintf(pathpfx, "%s/%s", xdgconfighome, dwmdir) <= 0) { - free(pathpfx); - return; - } - } else { - /* space for path segments, separators and nul */ - pathpfx = ecalloc(1, strlen(home) + strlen(localshare) - + strlen(dwmdir) + 3); - - if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) { + if (sprintf(pathpfx, "%s/%s", rootdir, dwmdir) <= 0) { free(pathpfx); return; } @@ -1436,21 +1405,9 @@ runautostart(void) /* check if the autostart script directory exists */ if (! (stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) { - /* the XDG conformant path does not exist or is no directory - * so we try ~/.dwm instead - */ - char *pathpfx_new = realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3); - if(pathpfx_new == NULL) { - free(pathpfx); - return; - } - - pathpfx = pathpfx_new; - - if (sprintf(pathpfx, "%s/.%s", home, dwmdir) <= 0) { - free(pathpfx); - return; - } + /* the specified dwm root directory does not exist or is not a directory */ + free(pathpfx); + return; } /* try the blocking script first */