How to add keyboard shortcuts to Awesome WM
You can add keyboard shortcuts by editing ~/.config/awesome/rc.lua
.
open rc.lua
in your favorite editor:
vim ~/.config/awesome/rc.lua
and to run firefox
with Super+Shift+w add the following line:
awful.key({ modkey, "Shift" }, "w", function () awful.util.spawn("firefox") end)
modkey
is usually Super key that can be changed in rc.lua
. Replace "firefox" with whatever program or command you want to run. Before defining your own keybindings checkout for predefined keybindings in rc.lua
to avoid conflicts.
Another example: dmrun
with Supre+r:
awful.key({ modkey, }, "r", function () awful.util.spawn("dmrun") end)
After making changes to rc.lua
its important to check configuration file for errors by running the following command:
awesome -k
You should see something like this:
✔ Configuration file syntax OK
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.