/* See LICENSE file for copyright and license details. */

#define TERM "st"
#define TERM_FLAG_NAME "-n"
#define TERM_FLAG_EXEC "-e"
#define TERM_FLAG_CLASS "-c"

#define BROWSER "floorp"
#define BROWSER_FLAG_INCOG "--private-window"
#define BROWSER_FLAG_1 "--disable-pinch"

#define STATUSBAR "dwmblocks"

/* 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 int focusonwheel      = 0;
static int floatposgrid_x          = 5;  /* float grid columns */
static int floatposgrid_y          = 5;  /* float grid rows */
/* Status is to be shown on: -1 (all monitors), 0 (a specific monitor by index), 'A' (active monitor) */

/* Indicators: see patch/bar_indicators.h for options */
static int tagindicatortype              = INDICATOR_NONE;
static int tiledindicatortype            = INDICATOR_NONE;
static int floatindicatortype            = INDICATOR_NONE;
static const int quit_empty_window_count = 0;   /* only allow dwm to quit if no (<= count) windows are open */
static const char font[]                 = "FiraCode Nerd Font 12";

#define BLACK "#15161E"
#define RED "#f7768e"
#define GREEN "#9ece6a"
#define ORANGE "#e0af68"
#define BLUE "#7aa2f7"
#define MAGENTA "#bb9af7"
#define CYAN "#7dcfff"
#define LIGHT_GRAY "#a9b1d6"
#define GRAY "#414868"
#define WHITE "#c0caf5"
#define UNDEFINED "#ff0000"

static char undefined[]              = UNDEFINED; // placeholder value

static char normfgcolor[]            = WHITE;
static char normbgcolor[]            = BLACK;
static char normbordercolor[]        = GRAY;
static char normfloatcolor[]         = GRAY;

static char selfgcolor[]             = UNDEFINED;
static char selbgcolor[]             = UNDEFINED;
static char selbordercolor[]         = BLUE;
static char selfloatcolor[]          = BLUE;

static char titlenormfgcolor[]       = WHITE;
static char titlenormbgcolor[]       = BLACK;
static char titlenormbordercolor[]   = UNDEFINED;
static char titlenormfloatcolor[]    = UNDEFINED;

static char titleselfgcolor[]        = LIGHT_GRAY;
static char titleselbgcolor[]        = BLACK;
static char titleselbordercolor[]    = UNDEFINED;
static char titleselfloatcolor[]     = UNDEFINED;

static char tagsnormfgcolor[]        = LIGHT_GRAY;
static char tagsnormbgcolor[]        = BLACK;
static char tagsnormbordercolor[]    = UNDEFINED;
static char tagsnormfloatcolor[]     = UNDEFINED;

static char tagsselfgcolor[]         = BLACK;
static char tagsselbgcolor[]         = BLUE;
static char tagsselbordercolor[]     = UNDEFINED;
static char tagsselfloatcolor[]      = UNDEFINED;

static char hidnormfgcolor[]         = UNDEFINED;
static char hidselfgcolor[]          = UNDEFINED;
static char hidnormbgcolor[]         = UNDEFINED;
static char hidselbgcolor[]          = UNDEFINED;

static char urgfgcolor[]             = BLACK;
static char urgbgcolor[]             = RED;
static char urgbordercolor[]         = RED;
static char urgfloatcolor[]          = RED;

static char scratchselfgcolor[]      = UNDEFINED;
static char scratchselbgcolor[]      = UNDEFINED;
static char scratchselbordercolor[]  = BLUE;
static char scratchselfloatcolor[]   = BLUE;

static char scratchnormfgcolor[]     = UNDEFINED;
static char scratchnormbgcolor[]     = UNDEFINED;
static char scratchnormbordercolor[] = GRAY;
static char scratchnormfloatcolor[]  = GRAY;

static char *colors[][ColCount] = {
	/*                       fg                bg                border                float */
	[SchemeNorm]        = { normfgcolor,        normbgcolor,        normbordercolor,        normfloatcolor },
	[SchemeSel]         = { selfgcolor,         selbgcolor,         selbordercolor,         selfloatcolor },
	[SchemeTitleNorm]   = { titlenormfgcolor,   titlenormbgcolor,   titlenormbordercolor,   titlenormfloatcolor },
	[SchemeTitleSel]    = { titleselfgcolor,    titleselbgcolor,    titleselbordercolor,    titleselfloatcolor },
	[SchemeTagsNorm]    = { tagsnormfgcolor,    tagsnormbgcolor,    tagsnormbordercolor,    tagsnormfloatcolor },
	[SchemeTagsSel]     = { tagsselfgcolor,     tagsselbgcolor,     tagsselbordercolor,     tagsselfloatcolor },
	[SchemeHidNorm]     = { hidnormfgcolor,     hidnormbgcolor,     undefined,              undefined },
	[SchemeHidSel]      = { hidselfgcolor,      hidselbgcolor,      undefined,              undefined },
	[SchemeUrg]         = { urgfgcolor,         urgbgcolor,         urgbordercolor,         urgfloatcolor },
	[SchemeScratchSel]  = { scratchselfgcolor,  scratchselbgcolor,  scratchselbordercolor,  scratchselfloatcolor },
	[SchemeScratchNorm] = { scratchnormfgcolor, scratchnormbgcolor, scratchnormbordercolor, scratchnormfloatcolor },
};

static char *tagicons[][NUMTAGS] =
{
	[DEFAULT_TAGS]        = { "1", "2", "3", "4", "5", "6", "7", "8", "9" },
};

static const int autostart_kill_signal = SIGHUP;
static const char *const autostart[] = {
    "/bin/sh", "-c", "exec run-parts \"${XDG_CONFIG_HOME}/dwm/autorun.d\"", NULL,
    "/bin/sh", "-c", "exec runsvdir \"${SVDIR}\"", NULL,
    NULL
};

static const char *spterm[] = { "t", TERM, TERM_FLAG_CLASS, "spterm", NULL };
static const char *spfile[] = { "f", TERM, TERM_FLAG_CLASS, "spfile", TERM_FLAG_EXEC, "lfX", NULL };
static const char *spchat[] = { "a", TERM, TERM_FLAG_CLASS, "spchat", TERM_FLAG_EXEC, "aichat", "-s", NULL };
static const char *spproc[] = { "p", TERM, TERM_FLAG_CLASS, "spproc", TERM_FLAG_EXEC, "btm", NULL };
static const char *spdisk[] = { "d", TERM, TERM_FLAG_CLASS, "spdisk", TERM_FLAG_EXEC, "dua", "i", "/", NULL };
static const char *spvolm[] = { "v", TERM, TERM_FLAG_CLASS, "spvolm", TERM_FLAG_EXEC, "ncpamixer", NULL };
static const char *sphelp[] = { "h", TERM, TERM_FLAG_CLASS, "sphelp", TERM_FLAG_EXEC, "glow", "-p", "-s", "tokyo-night", "/usr/share/doc/dwm/README.md", NULL };
static const char *spnetm[] = { "m", TERM, TERM_FLAG_CLASS, "spnetm", TERM_FLAG_EXEC, "/bin/sh", "-c", "sleep 0.01; nmtui", NULL }; // This sleep is needed to wait for DWM to size the window
static const char *spblue[] = { "b", TERM, TERM_FLAG_CLASS, "spnetm", TERM_FLAG_EXEC, "bluetuith", NULL };
static const char *spnetu[] = { "u", TERM, TERM_FLAG_CLASS, "spnetu", TERM_FLAG_EXEC, "bandwhich", NULL };
static const char *spwiki1[] = { "w", TERM, TERM_FLAG_CLASS, "spwiki", TERM_FLAG_EXEC, "/bin/sh", "-c", "sleep 0.01; zk edit -t index -i", NULL };
static const char *spwiki2[] = { "w", TERM, TERM_FLAG_CLASS, "spwiki", TERM_FLAG_EXEC, "/bin/sh", "-c", "sleep 0.01; zk edit -i", NULL };
static const char *sptask[] = { "s", TERM, TERM_FLAG_CLASS, "sptask", TERM_FLAG_EXEC, "taskwarrior-tui", NULL };
static const char *spcalc[] = { "c", TERM, TERM_FLAG_CLASS, "spcalc", TERM_FLAG_EXEC, "/bin/sh", "-c", "HOME=$XDG_DATA_HOME wcalc -C", NULL };

static const Rule rules[] = {
    /* xprop(1):
     *  WM_CLASS(STRING) = instance, class
     *  WM_NAME(STRING) = title
     *  WM_WINDOW_ROLE(STRING) = role
     *  _NET_WM_WINDOW_TYPE(ATOM) = wintype
     */
    RULE(.wintype = WTYPE "DIALOG", .isfloating = 1)
    RULE(.wintype = WTYPE "UTILITY", .isfloating = 1)
    RULE(.wintype = WTYPE "TOOLBAR", .isfloating = 1)
    RULE(.wintype = WTYPE "SPLASH", .isfloating = 1)
    RULE(.role = "pop-up", .isfloating = 1)
    RULE(.class = "Dragon-drop", .isfloating = 1, .iscentered = 1)
    RULE(.class = "St", .isfloating = 0)
    RULE(.class = "mpv", .isfloating = 0)
    RULE(.class = "Element", .monitor = 1, .tags = 1 << 0)
    RULE(.class = "Thunderbird", .monitor = 1, .tags = 1 << 1)
    RULE(.class = "sphelp", .scratchkey = 'h', .isfloating = 1, .iscentered = 1, .floatpos = "50% 50% 50% 90%")
    RULE(.class = "spwiki", .scratchkey = 'w', .isfloating = 1, .iscentered = 1, .floatpos = "50% 50% 50% 90%")
    RULE(.class = "sptask", .scratchkey = 's', .isfloating = 1, .iscentered = 1, .floatpos = "50% 50% 50% 90%")
    RULE(.class = "spterm", .scratchkey = 't', .isfloating = 1, .iscentered = 1, .floatpos = "50% 50% 90% 90%")
    RULE(.class = "spfile", .scratchkey = 'f', .isfloating = 1, .iscentered = 1, .floatpos = "50% 50% 90% 90%")
    RULE(.class = "spchat", .scratchkey = 'a', .isfloating = 1, .iscentered = 1, .floatpos = "50% 50% 90% 90%")
    RULE(.class = "spdisk", .scratchkey = 'd', .isfloating = 1, .iscentered = 1, .floatpos = "50% 50% 90% 90%")
    RULE(.class = "spproc", .scratchkey = 'p', .isfloating = 1, .iscentered = 1, .floatpos = "50% 50% 90% 90%")
    RULE(.class = "spnetu", .scratchkey = 'u', .isfloating = 1, .iscentered = 1, .floatpos = "50% 50% 90% 90%")
    RULE(.class = "spcalc", .scratchkey = 'c', .isfloating = 1, .floatpos = "100% 100% 600W 900H")
    RULE(.class = "spvolm", .scratchkey = 'v', .isfloating = 1, .floatpos = "100% 100% 900W 500H")
    RULE(.class = "spnetm", .scratchkey = 'm', .isfloating = 1, .floatpos = "100% 100% 900W 900H")
    RULE(.class = "spblue", .scratchkey = 'b', .isfloating = 1, .floatpos = "100% 100% 900W 900H")
};

static const BarRule barrules[] = {
	/* monitor bar alignment        widthfunc       drawfunc       clickfunc       hoverfunc   name */
	{ -1,      0,  BAR_ALIGN_LEFT,  width_tags,     draw_tags,     click_tags,     hover_tags, "tags" },
	{ -1,      0,  BAR_ALIGN_LEFT,  width_ltsymbol, draw_ltsymbol, click_ltsymbol, NULL,       "layout" },
	{  'A',    0,  BAR_ALIGN_RIGHT, width_status,   draw_status,   click_status,   NULL,       "status" },
	{ -1,      0,  BAR_ALIGN_NONE,  width_wintitle, draw_wintitle, click_wintitle, NULL,       "wintitle" },
};

/* layout(s) */
static const float mfact        = 0.50; /* factor of master area size [0.05..0.95] */
static const int nmaster        = 1;    /* number of clients in master area */
static const int resizehints    = 0;    /* 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[] = {
	/* symbol arrange function */
	{ "[]=",  tile },    /* first entry is default */
	{ "TTT",  bstack },
	{ ":::",  gaplessgrid },
	{ "><>",  NULL },    /* no layout function means floating behavior */
};


/* key definitions */
#define MODKEY Mod4Mask
#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 const char *termcmd[]  = { TERM, NULL };

#include <X11/XF86keysym.h>
static const Key keys[] = {
    /* START KEYBINDS */
    { MODKEY,             XK_F1,               togglescratch,      {.v = sphelp} }, // Toggle help
    // { MODKEY | ShiftMask,  XK_F1,              spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_F2,              spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenuhandler") },
    // { MODKEY | ShiftMask,  XK_F2,              spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_F3,              spawn,              SHCMD("$HOME/.local/libexec/dwm/togtouchpad") }, // Toggle touchpad
    // { MODKEY | ShiftMask,  XK_F3,              spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_F4,              spawn,              SHCMD("$HOME/.local/libexec/dwm/togcompositor") }, // Toggle compositor
    // { MODKEY | ShiftMask,  XK_F4,              spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_F5,              spawn,              {.v = (const char *[]){"clipmenu", NULL}} }, // Open copy/paste history
    // { MODKEY | ShiftMask,  XK_F5,              spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_F6,              spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_F6,              spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_F7,              spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_F7,              spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_F8,              spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_F8,              spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_F9,              spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenumount") },
    // { MODKEY | ShiftMask,  XK_F9,              spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_F10,             spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenuumount") },
    // { MODKEY | ShiftMask,  XK_F10,             spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_F11,             spawn,              SHCMD("$HOME/.local/libexec/dwm/displayselect") },
    // { MODKEY | ShiftMask,  XK_F11,             spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_F12,             spawn,              {.v = (const char *[]){"remaps", NULL}} }, // Rotate keyboard layout
    // { MODKEY | ShiftMask,  XK_F12,             spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_grave,           spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenuunicode --nocopy") }, // Insert an emoji
    { MODKEY | ShiftMask,  XK_grave,           spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenuunicode") }, // Copy an emoji
    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,              XK_0,               view,               {.ui = ~0} }, // View all tags
    { MODKEY | ShiftMask,  XK_0,               tag,                {.ui = ~0} }, // Make focused window sticky
    // { MODKEY | ShiftMask,  XK_0,               spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_bracketleft,     spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_bracketleft,     spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_bracketright,    spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_bracketright,    spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_BackSpace,       spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenusys") }, // Open shutdown menu
    // { MODKEY | ShiftMask,  XK_BackSpace,       spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_Tab,             spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_Tab,             spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_apostrophe,      spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_apostrophe,      spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_comma,           focusmon,           {.i = +1} }, // Focus next monitor
    { MODKEY | ShiftMask,  XK_comma,           tagmon,             {.i = +1} }, // Move focused window to next monitor
    { MODKEY,              XK_period,          focusmon,           {.i = -1} }, // Focus last monitor
    { MODKEY | ShiftMask,  XK_period,          tagmon,             {.i = -1} }, // Move focused window to last monitor
    { MODKEY,              XK_p,               spawn,              {.v = (const char *[]){"playerctl", "play-pause", NULL}} }, // Pause current player
    // { MODKEY | ShiftMask,  XK_p,               spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_y,               spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_y,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_f,               togglefullscreen,   {0} }, // Toggle fullscreen for focused window
    // { MODKEY | ShiftMask,  XK_f,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_g,               setlayout,          {.v = &layouts[0]} }, // Select default tile layout
    // { MODKEY | ShiftMask,  XK_g,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_c,               setlayout,          {.v = &layouts[1]} }, // Select bottom stack layout
    // { MODKEY | ShiftMask,  XK_c,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_r,               setlayout,          {.v = &layouts[2]} }, // Select grid layout
    // { MODKEY | ShiftMask,  XK_r,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_l,               pushstack,          {.i = INC(+1)} }, // Move focused window down stack
    { MODKEY | ShiftMask,  XK_l,               setmfact,           {.f = +0.05} }, // Increase size of master stack
    // { MODKEY,              XK_slash,           spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_slash,           spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_equal,           spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_equal,           spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_a,               togglescratch,      {.v = spchat} }, // Toggle AI chat
    // { MODKEY | ShiftMask,  XK_a,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_o,               togglescratch,      {.v = spproc} }, // Toggle process manager
    { MODKEY | ShiftMask,  XK_o,               togglescratch,      {.v = spnetu} }, // Toggle network usage analyzer
    { MODKEY,              XK_e,               togglescratch,      {.v = spfile} }, // Toggle file manager
    { MODKEY | ShiftMask,  XK_e,               togglescratch,      {.v = spdisk} }, // Toggle disk usage analyzer
    { MODKEY,              XK_u,               spawn,              {.v = (const char *[]){"dmenu_run", NULL}} }, // Run a program
    // { MODKEY | ShiftMask,  XK_u,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_i,               spawn,              {.v = (const char *[]){"dunstctl", "close", NULL}} }, // Close last notification
    { MODKEY | ShiftMask,  XK_i,               spawn,              {.v = (const char *[]){"dunstctl", "history-pop", NULL}} }, // Reopen last notification
    { MODKEY,              XK_d,               spawn,              {.v = (const char *[]){"dunstctl", "context", NULL}} }, // Select notification option
    { MODKEY | ShiftMask,  XK_d,               spawn,              {.v = (const char *[]){"dunstctl", "action", "0", NULL}} }, // Autoselect first notification option
    { MODKEY,              XK_h,               pushstack,          {.i = INC(-1)} }, // Move focused window up stack
    { MODKEY | ShiftMask,  XK_h,               setmfact,           {.f = -0.05} }, // Decrease size of master stack
    { MODKEY,              XK_t,               spawn,              {.v = (const char *[]){BROWSER, BROWSER_FLAG_1, NULL}} }, // Start a browser window
    { MODKEY | ShiftMask,  XK_t,               spawn,              {.v = (const char *[]){BROWSER, BROWSER_FLAG_1, BROWSER_FLAG_INCOG, NULL}} }, // Start an incognito browser window
    { MODKEY,              XK_n,               focusstack,         {.i = PREVSEL} }, // Focus last focused window
    { MODKEY | ShiftMask,  XK_n,               focusstack,         {.i = 0} }, // Focus master stack
    // { MODKEY,              XK_s,               spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_s,               spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_s,               spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_minus,           spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_minus,           spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_backslash,       spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_backslash,       spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_Return,          zoom,               {0} }, // Move focused window to master stack
    // { MODKEY | ShiftMask,  XK_Return,          spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_semicolon,       spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_semicolon,       spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_q,               killclient,         {0} }, // Close focused window
    // { MODKEY | ShiftMask,  XK_q,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_j,               focusstack,         {.i = INC(+1) } }, // Focus next window in stack
    /* { MODKEY | ShiftMask,  XK_j,               focusstack,         {.i = INC(+1) } }, */
    { MODKEY,              XK_k,               focusstack,         {.i = INC(-1) } }, // Focus last window in stack
    /* { MODKEY | ShiftMask,  XK_k,               focusstack,         {.i = INC(-1) } }, */
    { MODKEY,              XK_x,               togglefloating,     {0} }, // Toggle floating for focused window
    { MODKEY | ShiftMask,  XK_x,               unfloatvisible,     {0} }, // Unfloat visible floating windows
    { MODKEY,              XK_b,               togglescratch,      {.v = spnetm} }, // Toggle network manager
    { MODKEY | ShiftMask,  XK_b,               togglescratch,      {.v = spblue} }, // Toggle bluetooth manager
    { MODKEY,              XK_m,               togglescratch,      {.v = spvolm} }, // Toggle volume manager
    { MODKEY | ShiftMask,  XK_m,               spawn,              SHCMD("$HOME/.local/libexec/dwm/pamixer-notify -t") }, // Mute volume
    { MODKEY,              XK_w,               togglescratch,      {.v = spwiki1} }, // Toggle wiki
    { MODKEY | ShiftMask,  XK_w,               togglescratch,      {.v = spwiki2} }, // Toggle full wiki search
    { MODKEY,              XK_v,               togglescratch,      {.v = spcalc} }, // Toggle calculator
    // { MODKEY | ShiftMask,  XK_v,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_z,               togglescratch,      {.v = sptask} }, // Toggle task manager
    // { MODKEY | ShiftMask,  XK_z,               spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_space,           spawn,              {.v = termcmd} }, // Open terminal
    { MODKEY | ShiftMask,  XK_space,           togglescratch,      {.v = spterm} }, // Open scratch terminal
    { MODKEY,              XK_Print,           spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenurecord") }, // Open video recording menu
    { MODKEY | ShiftMask,  XK_Print,           spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenurecord kill") }, // Kill recording
    { 0,                   XK_Print,           spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenumaim full") }, // Screenshot full screen
    { ShiftMask,           XK_Print,           spawn,              SHCMD("$HOME/.local/libexec/dwm/dmenumaim") }, // Open screenshot menu
    // { MODKEY,              XK_Scroll_Lock,     spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_Scroll_Lock,     spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_Pause,           spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_Pause,           spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_Insert,          spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_Insert,          spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_Home,            spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_Home,            spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_Page_Up,         spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_Page_Up,         spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_Delete,          spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY | ShiftMask,  XK_Delete,          quit,               {0} }, // Kill window manager
    // { MODKEY,              XK_End,             spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_End,             spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY,              XK_Page_Down,       spawn,              {.v = (const char *[]){NULL}} },
    // { MODKEY | ShiftMask,  XK_Page_Down,       spawn,              {.v = (const char *[]){NULL}} },
    { MODKEY,              XK_Left,            spawn,              {.v = (const char *[]){"playerctl", "position", "5-", NULL}} }, // Spool current player back 5 seconds
    { MODKEY | ShiftMask,  XK_Left,            spawn,              {.v = (const char *[]){"playerctl", "previous", NULL}} }, // Skip to previous track in current player
    { MODKEY,              XK_Right,           spawn,              {.v = (const char *[]){"playerctl", "position", "5+", NULL}} }, // Spool current player forward 5 seconds
    { MODKEY | ShiftMask,  XK_Right,           spawn,              {.v = (const char *[]){"playerctl", "next", NULL}} }, // Skip to next track in current player
    { MODKEY,              XK_Up,              spawn,              SHCMD("$HOME/.local/libexec/dwm/pamixer-notify --allow-boost -i 5") }, // Increase volume
    { MODKEY | ShiftMask,  XK_Up,              spawn,              {.v = (const char *[]){"playerctl", "volume", "5+", NULL}} }, // Increase volume in player
    { MODKEY,              XK_Down,            spawn,              SHCMD("$HOME/.local/libexec/dwm/pamixer-notify --allow-boost -d 5") }, // Decrease volume
    { MODKEY | ShiftMask,  XK_Down,            spawn,              {.v = (const char *[]){"playerctl", "volume", "5-", NULL}} }, // Decrease volume in player

    { 0,             XF86XK_AudioMute,         spawn,              SHCMD("$HOME/.local/libexec/dwm/pamixer-notify -t") }, // Mute volume
    { 0,             XF86XK_AudioRaiseVolume,  spawn,              SHCMD("$HOME/.local/libexec/dwm/pamixer-notify --allow-boost -i 5") }, // Increase volume
    { 0,             XF86XK_AudioLowerVolume,  spawn,              SHCMD("$HOME/.local/libexec/dwm/pamixer-notify --allow-boost -d 5") }, // Decrease volume
    { 0,             XF86XK_AudioPrev,         spawn,              {.v = (const char *[]){"playerctl", "previous", NULL}} }, // Skip to previous track in current player
    { 0,             XF86XK_AudioNext,         spawn,              {.v = (const char *[]){"playerctl", "next", NULL}} }, // Skip to next track in current player
    { 0,             XF86XK_AudioPause,        spawn,              {.v = (const char *[]){"playerctl", "pause", NULL}} }, // Pause current player
    { 0,             XF86XK_AudioPlay,         spawn,              {.v = (const char *[]){"playerctl", "play-pause", NULL}} }, // Toggle pause/unpause in current player
    { 0,             XF86XK_AudioStop,         spawn,              {.v = (const char *[]){"playerctl", "stop", NULL}} }, // Stop current player
    { 0,             XF86XK_AudioRewind,       spawn,              {.v = (const char *[]){"playerctl", "position", "5-", NULL}} }, // Spool current player back 5 seconds
    { 0,             XF86XK_AudioForward,      spawn,              {.v = (const char *[]){"playerctl", "position", "5+", NULL}} }, // Spool current player forward 5 seconds
    // {             0, XF86XK_AudioMedia,        spawn,              {.v = (const char *[]){NULL}} },
    { 0,             XF86XK_AudioMicMute,      spawn,              SHCMD("$HOME/.local/libexec/dwm/togmic") }, // Toggle microphone mute
    { 0,             XF86XK_PowerOff,          spawn,              {.v = (const char *[]){"dmenusys", NULL}} }, // Open shutdown menu
    { 0,             XF86XK_Calculator,        togglescratch,      {.v = spcalc} }, // Toggle calculator
    { 0,             XF86XK_Sleep,             spawn,              {.v = (const char *[]){"loginctl", "suspend", "-i", NULL}} }, // Sleep system
    { 0,             XF86XK_WWW,               spawn,              {.v = (const char *[]){BROWSER, BROWSER_FLAG_1, NULL}} }, // Open browser
    // {             0, XF86XK_WLAN,              spawn,              {.v = (const char *[]){NULL}} },
    { 0,             XF86XK_DOS,               spawn,              {.v = (const char *[]){TERM, NULL}} }, // Open terminal
    { 0,             XF86XK_ScreenSaver,       spawn,              {.v = (const char *[]){"xset", "s", "activate", NULL}} }, // Lock session
    { 0,             XF86XK_TaskPane,          togglescratch,      {.v = spproc} }, // Toggle process manager
    // {             0, XF86XK_Mail,              spawn,              {.v = (const char *[]){NULL}} },
    { 0,             XF86XK_MyComputer,        togglescratch,      {.v = spfile} }, // Toggle file manager
    // {             0, XF86XK_Battery,           spawn,              {.v = (const char *[]){NULL}} },
    // {             0, XF86XK_Launch1,           spawn,              {.v = (const char *[]){NULL}} },
    { 0,             XF86XK_TouchpadToggle,    spawn,              SHCMD("$HOME/.local/libexec/dwm/togtouchpad") }, // Toggle touchpad
    { 0,             XF86XK_TouchpadOff,       spawn,              SHCMD("$HOME/.local/libexec/dwm/togtouchpad -n") }, // Disable touchpad
    { 0,             XF86XK_TouchpadOn,        spawn,              SHCMD("$HOME/.local/libexec/dwm/togtouchpad -y") }, // Enable touchpad
    { 0,             XF86XK_MonBrightnessUp,   spawn,              SHCMD("$HOME/.local/libexec/dwm/brightness-notify +5") }, // Increase monitor brightness
    { 0,             XF86XK_MonBrightnessDown, spawn,              SHCMD("$HOME/.local/libexec/dwm/brightness-notify -5") }, // Decrease monitor brightness
    /* END KEYBINDS */
};


/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static const 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} },
};