keychords & keys compile issue
Hello, I'm writing my issue in this repo as I based my dwm config on the dwm-distrotube. I was looking to add XF86 keys to change the volume and use toggle songs with mpc (toggle, next, prev). However, I get the following error when attempting to compile. I'm not sure if I need to define the keys in the Keychords section of my config. Has anyone else messed around with this? I have never coded in c before but I looked up someone else's github gist and followed the syntax. Thanks for your time.
Here is my compile error:
rm -f dwm drw.o dwm.o util.o dwm-6.3.tar.gz
dwm build options:
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/include/X11 -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION="6.3" -DXINERAMA
LDFLAGS = -L/usr/lib/X11 -lX11 -lXinerama -lfontconfig -lXft -lXrender
CC = cc
cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/include/X11 -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"6.3\" -DXINERAMA drw.c
cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/include/X11 -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"6.3\" -DXINERAMA dwm.c
In file included from dwm.c:301:
config.h:166:49: warning: excess elements in struct initializer
166 | { 0, XF86XK_AudioMute, spawn, {.v = togglvol } }
| ^~~~~
config.h:166:49: note: (near initialization for 'keys[0]')
config.h:166:65: error: extra brace group at end of initializer
166 | { 0, XF86XK_AudioMute, spawn, {.v = togglvol } }
| ^
config.h:166:65: note: (near initialization for 'keys[0]')
config.h:166:65: warning: excess elements in struct initializer
config.h:166:65: note: (near initialization for 'keys[0]')
config.h:167:9: error: expected '}' before '{' token
167 | { 0, XF86XK_AudioLowerVolume, spawn, {.v = lowervol } }
| ^
config.h:165:21: note: to match this '{'
165 | static Key keys[] = {
| ^
config.h:165:12: warning: 'keys' defined but not used [-Wunused-variable]
165 | static Key keys[] = {
| ^~~~
config.h:96:20: warning: 'prevmpc' defined but not used [-Wunused-variable]
96 | static const char *prevmpc[] = { "mpc", "prev", NULL };
| ^~~~~~~
config.h:95:20: warning: 'nextmpc' defined but not used [-Wunused-variable]
95 | static const char *nextmpc[] = { "mpc", "next", NULL };
| ^~~~~~~
config.h:94:20: warning: 'togglmpc' defined but not used [-Wunused-variable]
94 | static const char *togglmpc[] = { "mpc", "toggle", NULL };
| ^~~~~~~~
config.h:92:20: warning: 'lowervol' defined but not used [-Wunused-variable]
92 | static const char *lowervol[] = { "amixer", "set", "Master", "5%-", NULL };
| ^~~~~~~~
config.h:91:20: warning: 'raisevol' defined but not used [-Wunused-variable]
91 | static const char *raisevol[] = { "amixer", "set", "Master", "5%+", NULL };
| ^~~~~~~~
make: *** [Makefile:18: dwm.o] Error 1
Here is my config.h:
/* appearance */
static const unsigned int borderpx = 2; /* border pixel of windows */
static const unsigned int gappx = 8; /* gaps between 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 horizpadbar = 6; /* horizontal padding for statusbar */
static const int vertpadbar = 7; /* vertical padding for statusbar */
/* Default font will be Ubuntu if installed (ttf-ubuntu).
* Otherwise, your default font will be Hack (ttf-hack)
* JoyPixels (ttf-joypixels) is a dependency for colored fonts and emojis.
*/
static const char *fonts[] = {"Ubuntu:weight=bold:size=8:antialias=true:hinting=true",
"Hack:size=8:antialias=true:autohint=true",
"JoyPixels:size=10:antialias=true:autohint=true"
};
static const char col_1[] = "#282c34"; /* background color of bar */
static const char col_2[] = "#282c34"; /* border color unfocused windows */
static const char col_3[] = "#d7d7d7";
static const char col_4[] = "#ff699a"; /* border color focused windows and tags */
/* bar opacity
* 0xff is no transparency.
* 0xee adds wee bit of transparency.
* 0xdd adds adds a bit more transparency.
* Play with the value to get desired transparency.
*/
static const unsigned int baralpha = 0xff;
static const unsigned int borderalpha = OPAQUE;
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_3, col_1, col_2 },
[SchemeSel] = { col_3, col_4, col_4 },
};
static const unsigned int alphas[][3] = {
/* fg bg border */
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
[SchemeSel] = { OPAQUE, baralpha, borderalpha },
};
/* tagging */
/* static const char *tags[] = { "", "", "", "", "", "", "", "", "" }; */
static const char *tags[] = { "sys", "www", "vim", "vrt", "gms", "cht", "ifx", "sfx", "vfx" };
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 },
{ "brave-browser-stable", 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 = 0; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
#include "grid.c"
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "HHH", grid },
{ NULL, NULL },
};
/* key definitions */
#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{1, {{MODKEY, KEY}}, view, {.ui = 1 << TAG} }, \
{1, {{MODKEY|ControlMask, KEY}}, toggleview, {.ui = 1 << TAG} }, \
{1, {{MODKEY|ShiftMask, KEY}}, tag, {.ui = 1 << TAG} }, \
{1, {{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[] = { "dm-run", NULL };
static const char *termcmd[] = { "alacritty", NULL };
static const char *tabtermcmd[] = { "tabbed", "-r", "2", "st", "-w", "''", NULL };
/* volume */
#include <X11/XF86keysym.h>
static const char *togglvol[] = { "amixer", "set", "Master", "toggle", NULL };
static const char *raisevol[] = { "amixer", "set", "Master", "5%+", NULL };
static const char *lowervol[] = { "amixer", "set", "Master", "5%-", NULL };
/* music */
static const char *togglmpc[] = { "mpc", "toggle", NULL };
static const char *nextmpc[] = { "mpc", "next", NULL };
static const char *prevmpc[] = { "mpc", "prev", NULL };
static Keychord keychords[] = {
/* Keys function argument */
{1, {{MODKEY|ShiftMask, XK_Return}}, spawn, {.v = dmenucmd } },
{1, {{MODKEY, XK_Return}}, spawn, {.v = termcmd } },
{1, {{Mod1Mask, XK_Return}}, spawn, {.v = tabtermcmd } },
{1, {{MODKEY|ShiftMask, XK_c}}, killclient, {0} },
/* Dmenu scripts launched with keychords SUPER + p followed by "key" */
{2, {{MODKEY, XK_p}, {0, XK_e}}, spawn, SHCMD("dm-confedit") },
{2, {{MODKEY, XK_p}, {0, XK_i}}, spawn, SHCMD("dm-maim") },
{2, {{MODKEY, XK_p}, {0, XK_k}}, spawn, SHCMD("dm-kill") },
{2, {{MODKEY, XK_p}, {0, XK_l}}, spawn, SHCMD("dm-logout") },
{2, {{MODKEY, XK_p}, {0, XK_m}}, spawn, SHCMD("dm-man") },
{2, {{MODKEY, XK_p}, {0, XK_r}}, spawn, SHCMD("dm-reddit") },
{2, {{MODKEY, XK_p}, {0, XK_s}}, spawn, SHCMD("dm-websearch") },
{2, {{MODKEY, XK_p}, {0, XK_p}}, spawn, SHCMD("passmenu") },
/* Web browsers */
{1, {{MODKEY, XK_b}}, spawn, SHCMD("brave-browser-stable") },
{1, {{MODKEY, XK_o}}, togglebar, {0} },
{1, {{MODKEY, XK_j}}, focusstack, {.i = +1 } },
{1, {{MODKEY, XK_k}}, focusstack, {.i = -1 } },
{1, {{MODKEY|ShiftMask, XK_j}}, rotatestack, {.i = +1 } },
{1, {{MODKEY|ShiftMask, XK_k}}, rotatestack, {.i = -1 } },
{1, {{MODKEY, XK_i}}, incnmaster, {.i = +1 } },
{1, {{MODKEY, XK_d}}, incnmaster, {.i = -1 } },
{1, {{MODKEY, XK_h}}, setmfact, {.f = -0.05} },
{1, {{MODKEY, XK_l}}, setmfact, {.f = +0.05} },
{1, {{MODKEY, XK_Return}}, zoom, {0} },
{1, {{MODKEY, XK_Tab}}, view, {0} },
/* Layout manipulation */
{1, {{MODKEY, XK_Tab}}, cyclelayout, {.i = -1 } },
{1, {{MODKEY|ShiftMask, XK_Tab}}, cyclelayout, {.i = +1 } },
{1, {{MODKEY, XK_t}}, setlayout, {.v = &layouts[0]} },
{1, {{MODKEY, XK_f}}, setlayout, {.v = &layouts[1]} },
{1, {{MODKEY, XK_m}}, setlayout, {.v = &layouts[2]} },
{1, {{MODKEY, XK_g}}, setlayout, {.v = &layouts[3]} },
{1, {{MODKEY, XK_space}}, setlayout, {0} },
{1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} },
{1, {{MODKEY, XK_0}}, view, {.ui = ~0 } },
{1, {{MODKEY|ShiftMask, XK_0}}, tag, {.ui = ~0 } },
/* Switching between monitors */
{1, {{MODKEY, XK_comma}}, focusmon, {.i = -1 } },
{1, {{MODKEY, XK_period}}, focusmon, {.i = +1 } },
{1, {{MODKEY|ShiftMask, XK_comma}}, tagmon, {.i = -1 } },
{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)
/* Restart or quit dwm */
{1, {{MODKEY|ShiftMask, XK_r}}, quit, {1} },
{1, {{MODKEY|ShiftMask, XK_q}}, quit, {0} },
};
/* Music and Volume */
static Key keys[] = {
{ 0, XF86XK_AudioMute, spawn, {.v = togglvol } }
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = lowervol } }
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = raisevol } }
{ 0, XF86XK_AudioPlay, spawn, {.v = togglmpc } }
{ 0, XF86XK_AudioPrev, spawn, {.v = prevmpc } }
{ 0, XF86XK_AudioNext, spawn, {.v = nextmpc } }
};
/* 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} },
};