Awesome WM – How to Add Keyboard Shortcuts

awesomekeyboardserver

I've installed awesome3 wm on Ubuntu Server 10.04. I managed it to work properly now I could use some keyboard shortcuts to start programs like gmrun, firefox or whatever.

Best Answer

On Ubuntu 14.04.1 LTS, using Awesome version v3.4.15, (you can check version with command line: awesome -v)

Copying the configuration file to your home dir (file: rc.lua)

If you haven't yet copied the config files from system to your home directory, you can do that with

mkdir ~/.config/
mkdir ~/.config/awesome/
cp -r /etc/xdg/awesome/rc.lua ~/.config/awesome/

To copy the default themes as well, so you can change them for user level, do:

cp -r /usr/share/awesome/themes/ ~/.config/awesome

Then, you can edit rc.lua using your favourite editor, for example

vim ~/.config/awesome/rc.lua

Editing rc.lua

Find the text in the file

-- {{{ Key bindings
globalkeys = awful.util.table.join(

Below this you can add your custom commands, for example:

-- {{{ Key bindings
globalkeys = awful.util.table.join(
     -- My Bindings
     awful.key({ }, "F1", function () awful.util.spawn_with_shell("terminator") end),

Here you can change the key which here is F1, or program which here is terminator.

If you want to add composite keys, put them inside { }, for example:

-- {{{ Key bindings
globalkeys = awful.util.table.join(
     -- My Bindings
     awful.key({ modkey, "Control" }, "F1", function () awful.util.spawn_with_shell("terminator") end),

This would bind keys Super + Control + F1 to open terminator. modkey is a variable set in rc.lua, then it doesn't need (can't) to be escaped. It defaults for Superkey.

You can also put your keybindings at the end of globalkeys (after all the default keybindings), but if you do, make sure you avoid the ending comma , in the last keybinding, and add a closing comma to the last binding just before the last one, example:

-- {{{ Key bindings
globalkeys = awful.util.table.join(
   -- LOTS of stuff after:
     awful.key({ modkey }, "x",
               function ()
                   awful.prompt.run({ prompt = "Run Lua code: " },
                   mypromptbox[mouse.screen].widget,
                   awful.util.eval, nil,
                   awful.util.getdir("cache") .. "/history_eval")
               end),
     -- My Bindings
     awful.key({ }, "F1", function () awful.util.spawn_with_shell("terminator") end)
)

Pay attention to the last binding (the one that I created for F1); it has no ending comma, and the one before the last has a comma.

Then you can reload the configuration (default keys: Ctrl + Super + r) and see if the new configuration is working. When the user configuration rc.lua fails, Awesome loads the main one from the system. Otherwise, you can check the configuration file via terminal, with awesome -k.

Sorry if this was confusing. If anything is unclear just tell me and I can try to improve.

Related Question