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 utils = require "rc.configuration.bindings.utils" local capi = { awesome = _G.awesome, client = _G.client, } local global_keybindings = { -- Awesome akey { modifiers = { utils.mods.modkey }, key = "s", description = "show help", group = utils.groups.awesome, on_press = function() hotkeys_popup.show_help() end, }, akey { modifiers = { utils.mods.modkey }, key = "w", description = "show main menu", group = utils.groups.awesome, on_press = function() mymainmenu():show() end, }, akey { modifiers = { utils.mods.modkey, utils.mods.control }, key = "r", description = "reload awesome", group = utils.groups.awesome, on_press = capi.awesome.restart, }, akey { modifiers = { utils.mods.modkey, utils.mods.shift }, key = "q", description = "quit awesome", group = utils.groups.awesome, on_press = capi.awesome.quit, }, akey { modifiers = { utils.mods.modkey }, key = "x", description = "lua execute prompt", group = utils.groups.awesome, on_press = 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, }, -- Launcher akey { modifiers = { utils.mods.modkey }, key = "Return", description = "open a terminal", group = utils.groups.launcher, on_press = function() aspawn(applications.open_terminal()) end, }, akey { modifiers = { utils.mods.modkey }, key = "r", description = "run prompt", group = utils.groups.launcher, on_press = function() desktop_bar(ascreen.focused()).promptbox:run() end, }, akey { modifiers = { utils.mods.modkey }, key = "p", description = "show the menubar", group = utils.groups.launcher, on_press = function() menubar.show() end, }, -- Client focus akey { modifiers = { utils.mods.modkey }, key = "j", group = "client", description = "Focus next client by index", on_press = function() aclient.focus.byidx(1) end, }, akey { modifiers = { utils.mods.modkey }, key = "k", group = "client", description = "Focus previous by index", on_press = function() aclient.focus.byidx(-1) end, }, -- Layout manipulation akey { modifiers = { utils.mods.modkey, utils.mods.shift }, key = "j", group = "client", description = "Swap with next client", on_press = function() aclient.swap.byidx(1) end, }, akey { modifiers = { utils.mods.modkey, utils.mods.shift }, key = "k", group = "client", description = "Swap with previous client", on_press = function() aclient.swap.byidx(-1) end, }, akey { modifiers = { utils.mods.modkey, utils.mods.shift }, key = "Right", description = "Increase master width factor", group = "client", on_press = function() atag.incmwfact(0.01) end, }, akey { modifiers = { utils.mods.modkey, utils.mods.shift }, key = "Left", description = "Decrease master width factor", group = "client", on_press = function() atag.incmwfact(-0.01) end, }, -- Tags manipulation akey { modifiers = { utils.mods.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 = { utils.mods.modkey, utils.mods.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 = { utils.mods.modkey, utils.mods.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