/* See LICENSE file for copyright and license details. */
#include <X11/XF86keysym.h>

/* 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=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 },
	[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
};

/* tagging */
static const char *tags[] = {
	"TTY", "WEB", "DEV",
	"SBX", "GAM", "MED",
	"SYS", "SRV", "ETC"
};

static const Rule rules[] = {
	/* xprop(1):
	 *	WM_CLASS(STRING) = instance, class
	 *	WM_NAME(STRING) = title
	 */
	/* class      instance    title       tags mask     isfloating   monitor */
	{ "feh",      NULL,       NULL,       0,            1,           -1 },
	{ "zenity",   NULL,       NULL,       0,            1,           -1 },
};

/* layout(s) */
static const float mfact        = .5;   /* 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 int lockfullscreen = 1;    /* 1 will force focus on the fullscreen window */

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

/* key definitions */
#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
	{ MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
	{ MODKEY|ShiftMask,             KEY,      tag,            {.ui = 1 << TAG} }, \

/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[]      = { "dmenu_run", "-i", "-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 *lockcmd[]       = { "lock", NULL };
static const char *wwwcmd[]        = { "org.mozilla.firefox", NULL };
static const char *pwwwcmd[]       = { "org.mozilla.firefox", "--private-window", NULL };
static const char *calccmd[]       = { "alacritty", "-epython", NULL };
static const char *fmcmd[]         = { "pcmanfm", NULL };
static const char *prtsccmd[]      = { "sh", "-c", "gm import png:- | xclip -sel c -t image/png && xclip -sel c -o | feh -", NULL };
static const char *lvolcmd[]       = { "vol", "-5", NULL };
static const char *rvolcmd[]       = { "vol", "+5", NULL };
static const char *mutecmd[]       = { "vol", "m", NULL };
static const char *micmutecmd[]    = { "wpctl", "set-mute", "@DEFAULT_SOURCE@", "toggle", NULL };
static const char *pausecmd[]      = { "playerctl", "play-pause", NULL };
static const char *prevcmd[]       = { "playerctl", "previous", NULL };
static const char *nextcmd[]       = { "playerctl", "next", NULL };
static const char *stopcmd[]       = { "playerctl", "stop", NULL };
static const char *lbrtcmd[]       = { "light", "-10", NULL };
static const char *rbrtcmd[]       = { "light", "+10", NULL };
static const char *passselectcmd[] = { "passselect", NULL };
static const char *passopencmd[]   = { "passopen", NULL };
static const char *passusercmd[]   = { "passuser", NULL };
static const char *passpasscmd[]   = { "passpass", NULL };
static const char *passotpcmd[]    = { "passotp", NULL };

static const Key keys[] = {
	/* modifier                     key                       function        argument */
	{ MODKEY,                       XK_r,                     spawn,          {.v = dmenucmd } },
	{ MODKEY,                       XK_Return,                spawn,          {.v = termcmd } },
	{ MODKEY,                       XK_l,                     spawn,          {.v = lockcmd } },
	{ MODKEY,                       XK_b,                     spawn,          {.v = wwwcmd } },
	{ MODKEY|ShiftMask,             XK_b,                     spawn,          {.v = pwwwcmd } },
	{ 0,                            XF86XK_Calculator,        spawn,          {.v = calccmd } },
	{ MODKEY,                       XK_e,                     spawn,          {.v = fmcmd } },
	{ 0,                            XK_Print,                 spawn,          {.v = prtsccmd } },
	{ 0,                            XF86XK_AudioLowerVolume,  spawn,          {.v = lvolcmd } },
	{ 0,                            XF86XK_AudioRaiseVolume,  spawn,          {.v = rvolcmd } },
	{ 0,                            XF86XK_AudioMute,         spawn,          {.v = mutecmd } },
	{ 0,                            XF86XK_AudioMicMute,      spawn,          {.v = micmutecmd } },
	{ ShiftMask,                    XF86XK_AudioMute,         spawn,          {.v = micmutecmd } },
	{ 0,                            XF86XK_AudioPlay,         spawn,          {.v = pausecmd } },
	{ 0,                            XF86XK_AudioPrev,         spawn,          {.v = prevcmd } },
	{ 0,                            XF86XK_AudioNext,         spawn,          {.v = nextcmd } },
	{ 0,                            XF86XK_AudioStop,         spawn,          {.v = stopcmd } },
	{ 0,                            XF86XK_MonBrightnessDown, spawn,          {.v = lbrtcmd } },
	{ 0,                            XF86XK_MonBrightnessUp,   spawn,          {.v = rbrtcmd } },
	{ MODKEY,                       XK_p,                     spawn,          {.v = passselectcmd } },
	{ MODKEY|ShiftMask,             XK_p,                     spawn,          {.v = passopencmd } },
	{ MODKEY,                       XK_u,                     spawn,          {.v = passusercmd } },
	{ MODKEY,                       XK_i,                     spawn,          {.v = passpasscmd } },
	{ MODKEY,                       XK_o,                     spawn,          {.v = passotpcmd } },
	{ MODKEY,                       XK_j,                     focusstack,     {.i = +1 } },
	{ MODKEY,                       XK_k,                     focusstack,     {.i = -1 } },
	{ MODKEY|ShiftMask,             XK_z,                     zoom,           {0} },
	{ MODKEY|ShiftMask,             XK_c,                     killclient,     {0} },
	{ MODKEY,                       XK_t,                     setlayout,      {.v = &layouts[0] } },
	{ MODKEY,                       XK_m,                     setlayout,      {.v = &layouts[1] } },
	{ MODKEY,                       XK_space,                 togglefloating, {0} },
	{ MODKEY,                       XK_f,                     togglefullscr,  {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, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static const Button buttons[] = {
	/* click                event mask      button          function        argument */
	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
	{ ClkTagBar,            0,              Button1,        view,           {0} },
};
