1
0
awesomewm-config/keys.lua
2023-06-04 15:59:49 +03:00

94 lines
3.2 KiB
Lua

local keys = {}
local tag_amount = 5
local mod = 'Mod4'
local alt = "Mod1"
local ctrl = "Control"
local shift = "Shift"
keys.tags = tag_amount
local utils = require("utils")
local bindings = utils.bindings
local group = utils.group
local keybind = utils.keybind
local keybind_grp = utils.keybind_grp
local buttonbind = utils.buttonbind
local spawn_process = utils.wrap_spawn
-- Keybindings
awful.keyboard.append_global_keybindings(bindings{
group("awesome", {
keybind({mod, ctrl}, 'r', awesome.restart),
keybind({mod}, 'd', function() dashboard.toggle() end),
}),
--Hardware ( Laptop Users )
-- awful.key({}, 'XF86MonBrightnessUp', function() awful.spawn.with_shell('xbacklight +5') end),
-- awful.key({}, 'XF86MonBrightnessDown', function() awful.spawn.with_shell('xbacklight -5') end),
-- awful.key({}, 'XF86AudioRaiseVolume', function() awful.spawn.with_shell('pactl set-sink-volume @DEFAULT_SINK@ +5%') end),
-- awful.key({}, 'XF86AudioLowerVolume', function() awful.spawn.with_shell('pactl set-sink-volume @DEFAULT_SINK@ -4%') end),
-- Window management
group("window", {
keybind({alt}, 'Tab' , function() awful.client.focus.byidx(1) end),
keybind({mod}, 'Right', function() awful.tag.incmwfact(0.025) end),
keybind({mod}, 'Left' , function() awful.tag.incmwfact(-0.025) end),
keybind({mod}, 'Up' , function() awful.client.incwfact(0.05) end),
keybind({mod}, 'Down' , function() awful.client.incwfact(-0.05) end),
}),
-- Applications
group("apps", {
keybind({mod}, 'Return', spawn_process('kitty')),
keybind({alt}, 'space', spawn_process('rofi -show drun')),
}),
-- Playerctl
group("playerctl", {
keybind({ctrl, mod}, "Down" , function() require("playerctl"):play_pause() end),
keybind({ctrl, mod}, "Right", function() require("playerctl"):next() end),
keybind({ctrl, mod}, "Left" , function() require("playerctl"):previous() end)
}),
-- Screenshots
keybind({mod}, 's', function() awful.util.spawn('flameshot gui') end)
})
-- Keyboard Control
client.connect_signal('request::default_keybindings', function()
awful.mouse.append_client_mousebindings(bindings{
keybind({mod}, 'q' , function(c) c:kill() end),
keybind({mod}, 'm' , function(c) c.minimized = true end),
keybind({mod}, 'space', function(c) c.fullscreen = not c.fullscreen; c:raise() end),
keybind({mod}, 'Tab' , function() awful.client.floating.toggle() end)
})
end)
-- Mouse controls
client.connect_signal('request::default_mousebindings', function()
awful.mouse.append_client_mousebindings(bindings{
buttonbind({} , 1, function(c) client.focus = c end),
buttonbind({mod}, 1, function() awful.mouse.client.move() end),
buttonbind({mod}, 2, function(c) c:kill() end),
buttonbind({mod}, 3, function() awful.mouse.client.resize() end)
})
end)
-- Tag controls
awful.keyboard.append_global_keybindings(bindings{
keybind_grp({mod}, 'numrow', function(idx)
local screen = awful.screen.focused()
local tag = screen.tags[idx]
if tag then tag:view_only() end
end),
keybind_grp({mod, shift}, 'numrow', function(idx)
if client.focus then
local tag = client.focus.screen.tags[idx]
if tag then client.focus:move_to_tag(tag) end
end
end),
})
return keys