You are not logged in.

#1 2009-02-01 22:46:39

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

multimedia keycodes and dwm

Hey all - I've seen all of the posts about getting multimedia keys enabled in dwm and I've gotten dwm to recompile and run using their advice and a custom xmodmap file. However, my problem is that I can't seem to get the media keys in question to actually do anything. An over view of what I've done to get my multimedia keys can be found here: http://rhaamo.kelio.org/?p=18. This process has worked, but the multimedia key that I've assigned doesn't actually perform any actions when pressed.

Curiously, I'm also getting a strange response from xev from the key in question when running dwm. It doesn't seem as if the name I've assigned through xmodmap is being applied to the button when dwm is running.

My config.h:

static const char font[]            = "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*";
static const char normbordercolor[] = "#2E3436";
static const char normbgcolor[]     = "#2E3436";
static const char normfgcolor[]     = "#EEEEEC";
static const char selbordercolor[]  = "#3465a4";
static const char selbgcolor[]      = "#2E3436";
static const char selfgcolor[]      = "#EEEEEC";
static unsigned int borderpx        = 3;        /* border pixel of windows */
static unsigned int snap            = 32;       /* snap pixel */
static Bool showbar                 = True;     /* False means no bar */
static Bool topbar                  = True;     /* False means bottom bar */
static Bool readin                  = True;     /* False means do not read stdin */
static Bool usegrab                 = False;    /* True means grabbing the X server
                                                   during mouse-based resizals */

/* tagging */
static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */

static Rule rules[] = {
    /* class      instance    title       tags mask     isfloating */
    { "Gimp",     NULL,       NULL,       0,            True },
    { "Firefox",  NULL,       NULL,       1 << 8,       True },
};

/* layout(s) */
static float mfact      = 0.55; /* factor of master area size [0.05..0.95] */
static Bool resizehints = True; /* False means respect size hints in tiled resizals */

static Layout layouts[] = {
    /* symbol     arrange function */
    { "[T]",      tile },    /* first entry is default */
    { "[F]",      NULL },    /* no layout function means floating behavior */
    { "[M]",      monocle },
};

/* 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 *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[]  = { "terminal", NULL };

static Key keys[] = {
    /* modifier                     key        function        argument */
    /*Trying to add multimedia keys for MPD support */
    { 0,                XF86XK_AudioPlay,    spawn,    "exec mpc toggle" },
    { 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_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 } },
    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 a tag number (starting at 0),
 * 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} },
};

My .Xmodmap:

keycode 162 = XF86AudioPlay
keycode 144 = XF86AudioPrev 
keycode 164 = XF86AudioStop
keycode 153 = XF86AudioNext
keycode 160 = XF86AudioMute
keycode 176 = XF86AudioRaiseVolume
keycode 174 = XF86AudioLowerVolume

My xev output when the key is pressed (the key in question is 'XF86AudioPlay'):

FocusOut event, serial 24, synthetic NO, window 0xe00001,
    mode NotifyGrab, detail NotifyAncestor

FocusOut event, serial 24, synthetic NO, window 0xe00001,
    mode NotifyUngrab, detail NotifyPointer

FocusIn event, serial 24, synthetic NO, window 0xe00001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 24, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

I'm pretty stumped, as it seems that I've done everything correctly, but the key still fails to toggle MPD's output (and I do have mpc installed :-))

Any help would be greatly appreciated and I'll be more than happy to provide any more information that may be necessary.


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#2 2009-02-11 04:18:25

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: multimedia keycodes and dwm

synorgy wrote:

My xev output when the key is pressed (the key in question is 'XF86AudioPlay'):

FocusOut event, serial 24, synthetic NO, window 0xe00001,
    mode NotifyGrab, detail NotifyAncestor

FocusOut event, serial 24, synthetic NO, window 0xe00001,
    mode NotifyUngrab, detail NotifyPointer

FocusIn event, serial 24, synthetic NO, window 0xe00001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 24, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

I'm pretty stumped, as it seems that I've done everything correctly, but the key still fails to toggle MPD's output (and I do have mpc installed :-))

That xev output looks the same as when any window manager intercepts keys.

You might get more information as to what is going on if you start dwm in an xterm so you can look at its stdout when you press that key. If the exec mpc toggle happens or does anything, it will show up there, or replace it with exec xmessage "foo"

Offline

#3 2009-02-11 15:37:51

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: multimedia keycodes and dwm

Well, I've started working with dwm again, after a breif stint with awesome (which was unimpressive, contrary to its name...). I was getting frustrated, but I'll start working on this issue again (albeit with dwm from mercurial so I can track my patches easily rather than the stable version which is a crapshoot to track packages with.)

When I had no luck with 'mpc toggle' I replaced that with "zenity --message --text 'foo'" and I was still getting nothing, but I'll try this one again just to see how things go (especially with xmessage, as I wasn't sure on the format of the zenity messages, and starting dwm from a vt to check its output.)

Thanks!


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

Board footer

Powered by FluxBB