awesomewm-machina/init.lua

141 lines
4.1 KiB
Lua
Raw Normal View History

2021-06-10 16:28:28 +02:00
2021-06-27 07:48:46 +02:00
---------------------------------------------------------- dependencies -- ;
local capi = {root=root}
2021-06-10 16:28:28 +02:00
local gears = require("gears")
2021-06-27 07:48:46 +02:00
local naughty = require("naughty")
local inspect = require('inspect')
2021-06-10 16:28:28 +02:00
local awful = require("awful")
local modkey = "Mod4"
2021-06-27 07:48:46 +02:00
local machina = require('awesomewm-machina.methods')
2021-06-10 16:28:28 +02:00
2021-06-27 07:48:46 +02:00
local compare = machina.compare
local region_tablist = machina.region_tablist
local focus_by_direction = machina.focus_by_direction
local get_active_regions = machina.get_active_regions
local shift_by_direction = machina.shift_by_direction
local expand_horizontal = machina.expand_horizontal
local geoms = machina.geoms
local shuffle = machina.shuffle
local my_shifter = machina.my_shifter
local expand_vertical = machina.expand_vertical
2021-06-10 16:28:28 +02:00
2021-06-27 07:48:46 +02:00
---------------------------------------------------------- key bindings -- ;
2021-06-10 16:28:28 +02:00
2021-06-27 07:48:46 +02:00
local bindings = {
----------------╮
--│ SHUFFLE ◊◊
----------------╯
2021-06-27 08:15:25 +02:00
awful.key({modkey, "Shift"}, "j", shift_by_direction("left")),
--+ move client to left
2021-06-11 01:17:44 +02:00
2021-06-27 08:15:25 +02:00
awful.key({modkey, "Shift"}, "l", shift_by_direction("right")),
--+ move client to right
2021-06-11 07:28:10 +02:00
2021-06-27 08:15:25 +02:00
awful.key({modkey}, ";", shift_by_direction("left", true)),
--+ swap left
2021-06-10 16:28:28 +02:00
2021-06-27 08:15:25 +02:00
awful.key({modkey}, "'", shift_by_direction("right", true)),
--+ swap right
2021-06-10 16:44:01 +02:00
2021-06-27 07:48:46 +02:00
awful.key({modkey, "Shift"}, "[", my_shifter("backward")),
--+ custom shift client logic
2021-06-11 01:17:44 +02:00
2021-06-27 07:48:46 +02:00
awful.key({modkey, "Shift"}, "]", my_shifter("forward")),
--+ custom shift client logic
2021-06-11 04:29:09 +02:00
2021-06-27 07:48:46 +02:00
awful.key({modkey}, "[", shuffle("backward")),
2021-06-27 08:15:25 +02:00
--+ shuffle region backward
2021-06-10 16:44:01 +02:00
2021-06-27 07:48:46 +02:00
awful.key({modkey}, "]", shuffle("forward")),
2021-06-27 08:15:25 +02:00
--+ shuffle regions forward
2021-06-11 04:29:09 +02:00
2021-06-27 07:48:46 +02:00
----------------╮
--│ PLACEMENT ◊◊
----------------╯
awful.key({modkey}, "Insert", expand_horizontal("left")),
--+ expand to right
awful.key({modkey}, "Page_Up", expand_horizontal("right")),
--+ expand to left
2021-06-10 16:44:01 +02:00
2021-06-27 07:48:46 +02:00
awful.key({modkey}, "Home", expand_horizontal("center")),
--+ expand to center as float
2021-06-11 04:29:09 +02:00
2021-06-27 07:48:46 +02:00
awful.key({modkey}, "End", function()
client.focus.maximized_vertical = false
client.focus.maximized_horizontal = false
awful.client.floating.toggle()
2021-06-11 01:14:42 +02:00
end),
2021-06-27 07:48:46 +02:00
--+ toggle floating status
2021-06-11 01:14:42 +02:00
2021-06-27 07:48:46 +02:00
awful.key({modkey}, "Delete", expand_vertical),
--+ expand to right
2021-06-11 01:17:44 +02:00
2021-06-27 07:48:46 +02:00
----------------╮
--│ FOCUS ◊◊
----------------╯
awful.key({modkey}, "Left", focus_by_direction("left")),
awful.key({modkey}, "j", focus_by_direction("left")),
--+ stack friendly focus left
2021-06-10 20:41:12 +02:00
2021-06-27 07:48:46 +02:00
awful.key({modkey}, "Down", focus_by_direction("down")),
awful.key({modkey}, "k", focus_by_direction("down")),
--+ stack friendly focus down
2021-06-11 04:29:09 +02:00
2021-06-27 08:15:25 +02:00
awful.key({modkey}, "Right", focus_by_direction("right")),
2021-06-27 07:48:46 +02:00
awful.key({modkey}, "l", focus_by_direction("right")),
--+ stack friendly focus right
2021-06-11 01:14:42 +02:00
2021-06-27 07:48:46 +02:00
awful.key({modkey}, "Up", focus_by_direction("up")),
awful.key({modkey}, "i", focus_by_direction("up"))
--+ stack friendly focus up
2021-06-27 08:15:25 +02:00
2021-06-27 07:48:46 +02:00
}
2021-06-11 07:28:10 +02:00
2021-06-27 07:48:46 +02:00
--------------------------------------------------------------- signals -- ;
2021-06-11 07:28:10 +02:00
2021-06-27 07:48:46 +02:00
client.connect_signal("request::activate", function(c)
c.hidden = false
c:raise()
client.focus = c
end) ----| this is needed to ensure floating stuff becomes
----| visible when invoked through run_or_raise
2021-06-11 07:28:10 +02:00
2021-06-27 07:48:46 +02:00
client.connect_signal("focus", function(c)
if not c.floating then
for _, tc in ipairs(screen[awful.screen.focused()].all_clients) do
if tc.floating then
tc.hidden = true
end
end
return
end
2021-06-11 07:28:10 +02:00
2021-06-27 07:48:46 +02:00
if c.floating then
for _, tc in ipairs(screen[awful.screen.focused()].all_clients) do
if tc.floating and not tc.role then
tc.hidden = false
end
end
return
end
end) ----| hide all floating windows when the user switches to a
----| tiled client. this is handy when you have a floating
----| browser open.
2021-06-11 07:28:10 +02:00
2021-06-27 07:48:46 +02:00
--------------------------------------------------------------- exports -- ;
2021-06-10 16:28:28 +02:00
2021-06-27 07:48:46 +02:00
module = {
2021-06-27 08:15:25 +02:00
bindings = bindings
}
2021-06-10 16:28:28 +02:00
2021-06-27 07:48:46 +02:00
local function new(arg)
capi.root.keys(awful.util.table.join(capi.root.keys(), table.unpack(bindings)))
return module
end
2021-06-10 16:28:28 +02:00
2021-06-27 07:48:46 +02:00
return setmetatable(module, { __call = function(_,...) return new({...}) end })
2021-06-11 07:28:10 +02:00
2021-06-27 07:48:46 +02:00
-- return module