dotfiles/awesome/bindings/keys/global.lua

308 lines
8.3 KiB
Lua
Raw Normal View History

2023-05-23 05:12:23 +00:00
--- awesome stdlib
2023-04-20 04:08:44 +00:00
local gears = require("gears")
local awful = require("awful")
2023-05-23 05:12:23 +00:00
--- others
2023-04-20 04:08:44 +00:00
local hotkeys_popup = require("awful.hotkeys_popup")
2023-05-26 02:15:43 +00:00
local menubar = require("menubar")
2023-05-23 05:12:23 +00:00
--- resource configuration
2023-05-26 02:15:43 +00:00
local modkey = RC.vars.modkey
2023-04-20 04:08:44 +00:00
local terminal = RC.vars.terminal
local _M = {}
2023-05-23 05:12:23 +00:00
------------------
2023-04-20 04:08:44 +00:00
function _M.get()
2023-05-23 05:12:23 +00:00
local global_keys = gears.table.join(
2023-05-26 02:15:43 +00:00
--- show help [mod+s]
awful.key({ modkey }, "s",
hotkeys_popup.show_help,
{ description = "show help",
group = "awesome" }),
------------------
--------- tag browsing
--- view previous tag [global::mod+left]
awful.key({ modkey }, "Left",
awful.tag.viewprev,
{ description = "view previous",
group = "tag" }),
--- view next tag [global::mod+right]
awful.key({ modkey }, "Right",
awful.tag.viewnext,
{ description = "view next",
group = "tag" }),
------------------
--------- screen focus
awful.key({ modkey, "Control" }, "j",
function()
awful.screen.focus_relative( 1)
end,
{ description = "focus the next screen",
group = "screen" }),
awful.key({ modkey, "Control" }, "k",
function()
awful.screen.focus_relative(-1)
end,
{ description = "focus the previous screen",
group = "screen" }),
awful.key({ modkey }, "u",
awful.client.urgent.jumpto,
{ description = "jump to urgent client",
group = "client" }),
awful.key({ modkey }, "Tab",
function() awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end,
{ description = "go back",
group = "client" }),
------------------
--------- tiling manip
awful.key({ modkey, "Shift" }, "l",
function()
awful.tag.incmwfact( 0.05 )
end,
{ description = "increase master width factor",
group = "layout" }),
awful.key({ modkey, "Shift" }, "h",
function()
awful.tag.incmwfact( -0.05 )
end,
{ description = "decrease master width factor",
group = "layout" }),
awful.key({ modkey }, "h",
function()
awful.tag.incnmaster( 1, nil, true )
end,
{ description = "increase the number of master clients",
group = "layout" }),
awful.key({ modkey }, "l",
function()
awful.tag.incnmaster(-1, nil, true)
end,
{ description = "decrease the number of master clients",
group = "layout" }),
awful.key({ modkey, "Control" }, "h",
function()
awful.tag.incncol(1, nil, true)
end,
{ description = "increase the number of columns",
group = "layout" }),
awful.key({ modkey, "Control" }, "l",
function()
awful.tag.incncol(-1, nil, true)
end,
{ description = "decrease the number of columns",
group = "layout" }),
--------- client controls
------ focus switching
--- focus next client by index [global::mod+j]
awful.key({ modkey }, "j",
function()
awful.client.focus.byidx( 1)
end,
{ description = "focus next by index",
group = "client" }),
--- focus last client by index [global::mod+k]
awful.key({ modkey }, "k",
function()
awful.client.focus.byidx(-1)
end,
{ description = "focus previous by index",
group = "client" }),
------ reordering
--- swap with next client by index [global::mod+shift+j]
awful.key({ modkey, "Shift" }, "j",
function()
awful.client.swap.byidx( 1)
end,
{ description = "swap with next client by index",
group = "client" }),
--- swap with previous client by index [global::mod+shift+k]
awful.key({ modkey, "Shift" }, "k",
function()
awful.client.swap.byidx( -1)
end,
{ description = "swap with previous client by index",
group = "client" }),
------ resize
awful.key({ modkey, "Control" }, "Down",
function()
awful.client.moveresize(0, 0, 0, -20)
end),
awful.key({ modkey, "Control" }, "Up",
function()
awful.client.moveresize(0, 0, 0, 20)
end),
awful.key({ modkey, "Control" }, "Left",
function()
awful.client.moveresize(0, 0, -20, 0)
end),
awful.key({ modkey, "Control" }, "Right",
function()
awful.client.moveresize(0, 0, 20, 0)
end),
------ move
awful.key({ modkey, "Shift" }, "Down",
function()
awful.client.moveresize(0, 20, 0, 0)
end),
awful.key({ modkey, "Shift" }, "Up",
function()
awful.client.moveresize(0, -20, 0, 0)
end),
awful.key({ modkey, "Shift" }, "Left",
function()
awful.client.moveresize(-20, 0, 0, 0)
end),
awful.key({ modkey, "Shift" }, "Right",
function()
awful.client.moveresize(20, 0, 0, 0)
end),
awful.key({modkey, "Control" }, "n",
function() local c = awful.client.restore()
--- focus restored client
if c then c:emit_signal("request::activate",
"key.unminimize", {raise = true})
end
end,
{ description = "restore minimized",
group = "client" }),
------------------
--------- prompt
------ awesome
--- show main menu [global::mod+w]
awful.key({ modkey }, "w",
function()
RC.mainmenu:show()
end,
{ description = "show main menu",
group = "awesome" }),
--- reload awesome [global::mod+ctrl+r]
awful.key({ modkey, "Control" }, "r",
awesome.restart,
{ description = "reload awesome",
group = "awesome" }),
--- open the run prompt [global::mod+r]
awful.key({ modkey, "Shift" }, "r",
2023-05-26 02:15:43 +00:00
function()
awful.screen.focused().mypromptbox:run()
end,
{ description = "prompt: execute command",
group = "launcher" }),
--- open the lua code prompt [global::mod+x]
awful.key({ modkey }, "x",
function()
awful.prompt.run {
prompt = "Run Lua code: ",
textbox =
awful.screen.focused().mypromptbox.widget,
exe_callback = awful.util.eval,
history_path = awful.util.get_cache_dir() ..
"/history_eval" }
end,
{ description = "prompt: execute lua",
group = "awesome" }),
------ external
--- open terminal [global::mod+enter]
awful.key({ modkey }, "Return",
function()
awful.spawn(terminal)
end,
{ description = "open terminal",
group = "launcher" }),
--- take screenshot of entire screen [global::mod+y]
awful.key( {modkey }, "y",
function()
awful.util.spawn("scrot")
end,
{ description = "take fullscreen screenshot",
group = "launcher" }),
--- open rofi launcher [global::mod+p]
awful.key({ modkey }, "p",
function()
awful.util.spawn("rofi -show drun")
end,
{ description = "open rofi launcher",
group = "launcher" }),
--- ames: start/stop audio recording [global::mod+alt+r]
awful.key({ modkey, "Mod1" }, "r",
function()
awful.util.spawn("bash /home/nu/opt/ames/ames.sh -r")
end,
{ description = "start/stop audio recording",
group = "ames" }),
--- ames: screenshot selection [global::mod+alt+s]
awful.key({ modkey, "Mod1" }, "s",
function()
awful.util.spawn("bash /home/nu/opt/ames/ames.sh -s")
end,
{ description = "screenshot selection",
group = "ames" }),
--- ames: repeat previous screenshot selection [global::mod+alt+a]
awful.key({ modkey, "Mod1" }, "a",
function()
awful.util.spawn("bash /home/nu/opt/ames/ames.sh -a")
end,
{ description = "repeat previous screenshot selection",
group = "ames" }),
--- ames: screenshot active window [global::mod+alt+w]
awful.key({ modkey, "Mod1" }, "w",
function()
awful.util.spawn("bash /home/nu/opt/ames/ames.sh -w")
end,
{ description = "screenshot active window",
group = "ames" }),
--- ames: export copied text to card [global::mod+alt+c]
awful.key({ modkey, "Mod1" }, "c",
function()
awful.util.spawn("bash /home/nu/opt/ames/ames.sh -c")
end,
{ description = "export copied text to card",
group = "ames" })
2023-04-20 04:08:44 +00:00
)
2023-05-23 05:12:23 +00:00
return global_keys
2023-04-20 04:08:44 +00:00
end
2023-05-23 05:12:23 +00:00
------------------
2023-05-26 02:15:43 +00:00
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end })