0

Using a Dell Inspiron 15 7580. Awesome is version 4.3

I check the name of my keys using xev. Pressing my volume keys return the usual results.

KeyPress event, serial 36, synthetic NO, window 0x1200001,
    root 0x169, subw 0x1200002, time 13968342, (38,56), root:(841,97),
    state 0x0, keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x1200001,
    root 0x169, subw 0x1200002, time 13968484, (38,56), root:(841,97),
    state 0x0, keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

So I bind the key to AwesomeWM...

awful.key({ }, "XF86AudioLowerVolume", 
    awful.spawn("amixer set Master 5%-"), {})

But once I refresh Awesome, the binding doesn't work AND xev returns a different result

FocusOut event, serial 36, synthetic NO, window 0x1800001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 36, synthetic NO, window 0x1800001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 36, synthetic NO, window 0x0,
    keys:  105 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

The function keys work again once I unbind them. But why is this occurring? It's not even my volume key once I bind it.

1 Answer 1

0

I figured it out. For some reason, I had to use awful.spawn inside an anonymous function. I'd figured since awful.spawn was a function, I didn't have to do this. But you do, unfortunately.

awful.key({ }, "XF86AudioLowerVolume", function() 
    awful.spawn("amixer set Master 5%-") 
end, 
{description = "lower audio", group = "audio"}),

EDIT Figured I'd explain it.

So the press argument to key.new (__call metatable for awful.key) requires a function as an argument. awful.spawn is of type function, but what's returned by it isn't a function. So for times like these, one can only pass a function as an argument, rather than calling the function.

Good example

-- Notice I passed awful.spawn without calling it
awful.key({ }, "t", awful.spawn, {})

Bad example

-- awful.spawn is called here, so whats returned by it is passed as an argument
awful.key({ }, "t", awful.spawn(), {})

Remember that you can always check your types in lua by calling type.

type(awful.spawn)
function
1
  • Good job figuring it out! This is because Awesome knows how to call a function as a callback, but has no way of knowing what arguments to send to that function at the time of the event. Same goes for other languages/frameworks with callbacks. Commented Aug 26, 2019 at 5:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.