awesomerc/configuration/global_keybindings.lua

185 lines
4.7 KiB
Lua

local aclient = require "awful.client"
local akey = require "awful.key"
local aprompt = require "awful.prompt"
local ascreen = require "awful.screen"
local aspawn = require "awful.spawn"
local atag = require "awful.tag"
local autil = require "awful.util"
local menubar = require "menubar"
local applications = require "rc.configuration.applications"
local desktop_bar = require "rc.ui.desktop_decoration.bar"
local hotkeys_popup = require "rc.ui.hotkeys_popup"
local mymainmenu = require "rc.ui.menu.mymainmenu"
local capi = {
awesome = _G.awesome,
client = _G.client,
}
local control = "Control"
local modkey = "Mod4"
local shift = "Shift"
local global_keybindings = {
akey({ modkey }, "s", function()
hotkeys_popup.show_help()
end, {
description = "show help",
group = "awesome",
}),
akey({ modkey }, "w", function()
mymainmenu():show()
end, {
description = "show main menu",
group = "awesome",
}),
akey(
{ modkey, control },
"r",
capi.awesome.restart,
{ description = "reload awesome", group = "awesome" }
),
akey(
{ modkey, shift },
"q",
capi.awesome.quit,
{ description = "quit awesome", group = "awesome" }
),
akey({ modkey }, "x", function()
aprompt.run {
prompt = "Run Lua code: ",
textbox = desktop_bar(ascreen.focused()).promptbox.widget,
exe_callback = autil.eval,
history_path = autil.get_cache_dir() .. "/history_eval",
}
end, {
description = "lua execute prompt",
group = "awesome",
}),
akey({ modkey }, "Return", function()
aspawn(applications.open_terminal())
end, {
description = "open a terminal",
group = "launcher",
}),
akey({ modkey }, "r", function()
desktop_bar(ascreen.focused()).promptbox:run()
end, {
description = "run prompt",
group = "launcher",
}),
akey({ modkey }, "p", function()
menubar.show()
end, {
description = "show the menubar",
group = "launcher",
}),
-- Client focus
akey {
modifiers = { modkey },
key = "j",
group = "client",
description = "Focus next client by index",
on_press = function()
aclient.focus.byidx(1)
end,
},
akey {
modifiers = { modkey },
key = "k",
group = "client",
description = "Focus previous by index",
on_press = function()
aclient.focus.byidx(-1)
end,
},
-- Layout manipulation
akey {
modifiers = { modkey, shift },
key = "j",
group = "client",
description = "Swap with next client",
on_press = function()
aclient.swap.byidx(1)
end,
},
akey {
modifiers = { modkey, shift },
key = "k",
group = "client",
description = "Swap with previous client",
on_press = function()
aclient.swap.byidx(-1)
end,
},
akey {
modifiers = { modkey, shift },
key = "Right",
description = "Increase master width factor",
group = "client",
on_press = function()
atag.incmwfact(0.01)
end,
},
akey {
modifiers = { modkey, shift },
key = "Left",
description = "Decrease master width factor",
group = "client",
on_press = function()
atag.incmwfact(-0.01)
end,
},
-- Tags manipulation
akey {
modifiers = { modkey },
keygroup = akey.keygroup.NUMROW,
description = "only view tag",
group = "tag",
on_press = function(index)
local screen = ascreen.focused()
local tag = screen.tags[index]
if tag then
tag:view_only()
end
end,
},
akey {
modifiers = { modkey, control },
keygroup = akey.keygroup.NUMROW,
description = "toggle tag",
group = "tag",
on_press = function(index)
local screen = ascreen.focused()
local tag = screen.tags[index]
if tag then
atag.viewtoggle(tag)
end
end,
},
akey {
modifiers = { modkey, shift },
keygroup = akey.keygroup.NUMROW,
description = "move focused client to tag",
group = "tag",
on_press = function(index)
local screen = ascreen.focused()
local client = capi.client.focus
local tag = screen.tags[index]
if client and tag then
client:move_to_tag(tag)
end
end,
},
}
return global_keybindings