Search code examples
linuxkey-bindingsarch

dwm arch linux. How to make key bindings to run Terminal programs


I was using i3. Now I want to see dwm. Made keybidings to run firefox on Modkey+w. It works well, but now when I want to do similar commands for nvim, ranger, cmus (all terminal programs) it isn't working. Can't run them from dmenu also. Is it ok, or I just fiddled with my config files?

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 },
    { "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
    { "nvim",       NULL,       NULL,       1 << 8,       0,           -1 },
    { "ranger",     NULL,       NULL,       1 << 8,       0,           -1 },

};
static const char *web[]  = { "/usr/bin/firefox", NULL };
static const char *nvim[]  = { "/usr/share/nvim", NULL };
static const char *ranger[]  = { "/usr/bin/ranger", NULL };

{ MODKEY,                       XK_w,        spawn,                  {.v = web } },
{ MODKEY,                       XK_r,        spawn,                  {.v = ranger } },
{ MODKEY|ShiftMask,                       XK_v,          spawn,                  {.v = nvim } },

Solution

  • Nvim and Ranger run in the terminal, so just running the binaries won't do anything. You'll need to run them in your terminal. How that works depends on your terminal, but it is likely something like your-terminal -e ranger, or static const char *ranger[] = {"xterm", "-e", "/usr/bin/ranger", NULL }; for example.