You are not logged in.
Hi there, first time posting here so I'm putting this here.
So I have installed dwm recently and I am modifying the `config.def.h` file to set Alt+ F3, Alt + F2, Alt + F1, and Shift + Alt + F1 to increase volume, decrease volume, mute, and unmute, respectively, but the changes are not being applied when I compile the code.
I compile the code using the command
rm config.h && make followed by
sudo make clean install .
This is my code in `config.def.h`:
/* volume control commands */
static const char *volunmutecmd[] = {"pamixer", "--unmute", NULL};
static const char *volmutecmd[] = {"pamixer", "--mute", NULL};
static const char *volupcmd[] = {"pamixer", "--increase", "5", NULL};
static const char *voldowncmd[] = {"pamixer", "--decrease", "5", NULL};[/ins]
[ins]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} },
{ MODKEY, XK_F2, spawn, {.v = voldowncmd } },
{ MODKEY, XK_F3, spawn, {.v = volupcmd } },
{ MODKEY, XK_F1, spawn, {.v = volmutecmd } },
{ MODKEY|ShiftMask, XK_F1, spawn, {.v = volunmutecmd } },
};The changes that I made to the Key array are the last four entries below. From the spawn() function in dwm.c, it seems like the array of arguments that I defined above should be fed into execvp(). I am assuming that the macros are taken from X11/keysymdef.h.
On my terminal, running a command like
pamixer --mute or
pamixer --increase 5 performs the intended action (that is, mute and increase volume by 5), so I'm not sure if it's an issue with execvp(), or something else.
The other key bindings defined in the Key array work.
Last edited by Jujubee (2022-06-14 11:46:28)
Offline
Nothing jumps out at me other than what I suspect is a copy paste error with a couple stray "ins" tag after the definition of the voldowncmd and before the binding array. If that were in the actual file, it'd result in a error during compilation. But just to be sure, make completes *successfully* right? Also, pardon me if this is obvious, but you are restarting dwm after your recompile / install, right?
The other key bindings defined in the Key array work.
Have you changed any others to ensure changes are included in the new dwm? Assuming you have, my next troubleshooting step would be to swap the key/actions between working bindings and non-working ones. For example, if you swap the volume up and the dmenu bindings, does the MOD+F1 successfully open dmenu and / or does Mod+p change the volume? This would narrow down whether the issue is with the pamixer command or the key itself.
Last edited by Trilby (2022-06-14 13:54:41)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
jStrangely, when I change the
termcdbind to Shift + Alt + F4, it successfully rebinds the key. That is, when I change
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },to
{ MODKEY|ShiftMask, XK_F4 , spawn, {.v = termcmd } },and then compile, and then restart DWM, it applies that keybind. For reference, termcd is the array
static const char *termcd[] = { "alacritty", NULL};And yeah, I'm exiting dwm and then going back into it with startx. And the "ins" tag is just a formatting error I made when making the post - the code compiles with no issues at all.
UPDATE: Changing the code to
{ MODKEY|ShiftMask, XK_F1 , spawn, {.v = termcmd } },doesn't work for some reason - that is, pressing Shift + Alt + F1 doesn't execute the terminal as expected. So I tried binding mute to Alt + F4, and it works! I have no idea why binding it to Alt + F1, Alt + F2 and Alt + F3 doesn't work.
I really want to bind it to those specific key binds since my laptop's F1, F2 and F3 keys have the volume control symbols on them.
UPDATE 2: I notice that Alt + F5 also doesn't work when I try binding the termcd command to it.
Last edited by Jujubee (2022-06-15 02:18:58)
Offline
I really want to bind it to those specific key binds since my laptop's F1, F2 and F3 keys have the volume control symbols on them.
But you don't want to use the Fn+F1, Fn+F2, Fn+F3 and bind the XF86XK_AudioRaiseVolume, XF86XK_AudioLowerVolume, and XF86XK_AudioMute?
Are you sure these keys aren't generating a keysym like this anyways? Remove these new bindings, restart dwm, then use xev to check / confirm what syms these key combinations are actually generating (and / or detect whether they are already bound by another process).
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline