2

I'm new to awesome wm and I'm trying to bind a key to another key. e.g.

When I press alt+j, it will act like I just pressed the down key on keyboard.

I don't know whether awesome wm has this function or not?

Any function like this?

awful.key({ altkey }, "j", function () "down"
APC
  • 144,005
  • 19
  • 170
  • 281
hhuimie
  • 31
  • 5

4 Answers4

1

I think I may be misunderstanding your question.

Interpretation 1:

Just copy the code from that other key binding.

In the default config, mod+j is:

awful.key({ modkey,           }, "j",                                                                                                                                                
    function ()
        awful.client.focus.byidx( 1)
        if client.focus then client.focus:raise() end
    end),

Copy that part and change the key:

awful.key({ }, "Down",                                                                                                                                                
    function ()
        awful.client.focus.byidx( 1)
        if client.focus then client.focus:raise() end
    end),

Interpretation 2:

awful.key({ modkey,           }, "j",                                                                                                                                                
    function ()
        root.fake_input("key_press", "Down")
        root.fake_input("key_release", "Down")
    end),
Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39
  • Sorry for my poor english! Explain again: I don't wanna click the "up""down" key, so I wanna use "alt+j" to replace the "down" key. I had tried your Interpretation 2. It didn't work. What if delay this function. But I don't know how to delay the function. Thank you very much! – hhuimie Jan 16 '16 at 15:13
1

Finally, I found a not perfect solution. First, install xdotool, I'm using ArchLinux, so:

yaourt -S xdotool

And edit ~/.config/awesome/rc.lua

awful.key({ altkey }, "j", function() 
    awful.util.spawn("sh -c 'xdotool sleep 0.1 key --clearmodifiers Down'") end),

But somehow it will just input j, and I don't know why.

hhuimie
  • 31
  • 5
0

This worked for me for gtk2 applications:

awful.key({ "Control",        }, "n",      function (c) awful.util.spawn_with_shell("xdotool getactivewindow key --window %1 Down")        end)
ivanp
  • 1
-1

As their documentation says, there is a config file located in

$XDG_CONFIG_HOME/awesome/rc.lua.

I do not have awesome vm installed to tell you exactly what to change inside but you will figure it out easily. Also, to completely change the path of the config file use :

-c, --config FILE

Use an alternate configuration file instead of $XDG_CONFIG_HOME/awesome/rc.lua.

ctotolin
  • 183
  • 5