Title: Configuring Keybinds in awesomeWM Ubuntu
In this article, we will guide you on how to configure keybinds in awesomeWM, a dynamic window manager for X11, on Ubuntu.
Prerequisites
Before we dive into the configuration, ensure you have the following:
- Installed awesomeWM: You can install it via the terminal using the command
sudo apt-get install awesome. - Familiarity with Lua scripting: The keybindings are defined in a Lua script (
src.lua).
Keybind Configuration
The keybind configuration file for awesomeWM is src.lua. Let's take a look at the file structure:
-- Default awesome configuration file
-- Global variables
awful.modkey = { Mod4, Super_L } -- Windows key
awful.taglist_awsome_tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }
-- Callback function to execute commands
local function run_or_toggle(cmd_or_toggle)
-- The first argument will always be the script that creates an instance
local c = awful.client.restore(cmd_or_toggle)
if not c then
-- We will make no assumptions about the string we've just been given
-- and will try to spawn the command through the os.execute() function
-- in the hope that it works...
local start_search, program, args = string.find(cmd_or_toggle, "([^%s]+)(%s+)?")
if not start_search then
return
end
program = cmd_or_toggle
args = {}
end
-- Does the window already exist?
if c then
-- If it does, the window already has a tag assigned. No need to do anything.
c:raise()
else
-- If not, the window will be inserted as "empty". We will just set the
-- window's class to the name of the program to enable it to be
-- auto-managed by awsome.
c = awful.screen.focused().awful.client.create({ className = program })
c:setproperty("class", program)
c:setontop()
c:move_to_tag(awful.taglist_get_tag_by_index(1))
c:raise()
end
end
-- Keybindings
globalkeys = awful.util.table.join(
awful.key({ awful.modkey }, "Return", function() run_or_toggle("firefox") end),
awful.key({ awful.modkey }, "Tab", function() awful.client.focus.byidx(1) end),
awful.key({ awful.modkey }, "j", function() awful.client.focus.byidx(1) end),
awful.key({ awful.modkey }, "k", function() awful.client.focus.byidx(-1) end),
awful.key({ awful.modkey }, "w", function() awful.client.kill() end)
)
-- Reload awesome
local function reload_awesome()
awesome.restart()
end
-- Bind reload_awesome to the F5 key
clientkeys = awful.util.table.join(
awful.key({}, "F5", reload_awesome)
)
-- Ensure awesome-client is reloaded when the window manager is restarted
awesome.connect_signal("client::manage", function(c)
if awesome.startup then
-- If we are starting up, then it's our job to open the window.
c.open_window()
end
end)
Customizing Keybinds
To customize the keybinds, you can modify the globalkeys and clientkeys tables. For example, to add a keybind for Google Chrome, you can add the following line to the globalkeys table:
awful.key({ awful.modkey }, "g", function() run_or_toggle("google-chrome") end),
Reloading awesomeWM
To reload the configuration, you can use the command reload:awesome-client. In the clientkeys table, we have bound this command to the F5 key.
Summary
In this article, we covered how to configure keybinds in awesomeWM on Ubuntu. We discussed the keybind configuration file src.lua, keybind customization, and reloading the configuration.