1

I'm trying to configure a keyboard event in the awesome wm which should work like this:

After Key "XF86AudioMute" is pressed the user has 2 seconds to press a number key (from 0 - 9) in order to activate the event. If none of these keys is pressed after this time (ideally as well if any other key is pressed) listening for the number keys is aborted. Also if a number key was pressed of course.

Anybody has an idea how I could approach this in the awesome config file?

Anton Harald
  • 5,772
  • 4
  • 27
  • 61

1 Answers1

0

Awesome has keygrabbers and timers. When XF86AudioMute is pressed, you would start a timer that fires in two seconds and a keygrabber that gets all input.

Something like the following (note that you still need to set up the keybinding to XF86AudioMute):

function do_stuff()
  local t = timer({ timeout = 2 })
  t:start()
  local grabber
  local function cleanup()
    t:stop()
    awful.keygrabber.stop(grabber)
  end
  t:connect_signal("timeout", cleanup)
  grabber = function(mod, key, event)
    if event == "release" then return end
    if key = "1" then
      naughty.notify({ text = "event 1 activated" })
    end
    cleanup()
  end
  awful.keygrabber.run(grabber)
end

Edit: By the way, I never tested this code and don't know if it actually works!

Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39