2021-06-10 16:28:28 +02:00
|
|
|
|
2021-06-27 07:48:46 +02:00
|
|
|
---------------------------------------------------------- dependencies -- ;
|
2021-06-28 03:23:53 +02:00
|
|
|
|
2021-06-27 07:48:46 +02:00
|
|
|
local capi = {root=root}
|
2021-06-10 16:28:28 +02:00
|
|
|
local awful = require("awful")
|
|
|
|
local modkey = "Mod4"
|
|
|
|
|
2021-07-03 23:50:31 +02:00
|
|
|
local machina = require("machina.methods")
|
|
|
|
local backham = require("machina.backham")
|
2021-06-27 07:48:46 +02:00
|
|
|
local focus_by_direction = machina.focus_by_direction
|
|
|
|
local shift_by_direction = machina.shift_by_direction
|
|
|
|
local expand_horizontal = machina.expand_horizontal
|
|
|
|
local shuffle = machina.shuffle
|
|
|
|
local my_shifter = machina.my_shifter
|
|
|
|
local expand_vertical = machina.expand_vertical
|
2021-06-28 07:58:41 +02:00
|
|
|
local move_to = machina.move_to
|
2021-06-28 13:27:03 +02:00
|
|
|
local toggle_always_on = machina.toggle_always_on
|
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 = {
|
2021-07-03 23:50:31 +02:00
|
|
|
awful.key({modkey}, "[", my_shifter("backward")),
|
|
|
|
awful.key({modkey}, "]", my_shifter("forward")),
|
|
|
|
--▨ move
|
|
|
|
|
|
|
|
awful.key({modkey, "Shift"}, "[", my_shifter("backward", "swap")),
|
|
|
|
awful.key({modkey, "Shift"}, "]", my_shifter("forward", "swap")),
|
|
|
|
--▨ swap
|
|
|
|
|
2021-06-28 03:23:53 +02:00
|
|
|
awful.key({modkey}, ";", shuffle("backward")),
|
|
|
|
awful.key({modkey}, "'", shuffle("forward")),
|
2021-07-03 23:50:31 +02:00
|
|
|
--▨ shuffle
|
|
|
|
|
|
|
|
awful.key({modkey}, "j", focus_by_direction("left")),
|
|
|
|
awful.key({modkey}, "k", focus_by_direction("down")),
|
|
|
|
awful.key({modkey}, "l", focus_by_direction("right")),
|
|
|
|
awful.key({modkey}, "i", focus_by_direction("up")),
|
|
|
|
--▨ focus
|
2021-06-28 03:23:53 +02:00
|
|
|
|
2021-06-27 08:15:25 +02:00
|
|
|
awful.key({modkey, "Shift"}, "j", shift_by_direction("left")),
|
|
|
|
awful.key({modkey, "Shift"}, "l", shift_by_direction("right")),
|
2021-06-28 02:24:49 +02:00
|
|
|
awful.key({modkey, "Shift"}, "k", shift_by_direction("down")),
|
|
|
|
awful.key({modkey, "Shift"}, "i", shift_by_direction("up")),
|
2021-07-03 23:50:31 +02:00
|
|
|
--▨ move
|
2021-06-10 16:44:01 +02:00
|
|
|
|
2021-07-03 23:50:31 +02:00
|
|
|
awful.key({modkey, "Control"}, "j", shift_by_direction("left", "swap")),
|
|
|
|
awful.key({modkey, "Control"}, "l", shift_by_direction("right", "swap")),
|
|
|
|
awful.key({modkey, "Control"}, "k", shift_by_direction("down", "swap")),
|
|
|
|
awful.key({modkey, "Control"}, "i", shift_by_direction("up","swap")),
|
|
|
|
--▨ swap
|
2021-06-28 07:58:41 +02:00
|
|
|
|
2021-07-03 23:50:31 +02:00
|
|
|
awful.key({modkey, "Shift"}, "Insert", expand_horizontal("left")),
|
|
|
|
awful.key({modkey, "Shift"}, "Page_Up", expand_horizontal("right")),
|
|
|
|
awful.key({modkey, "Shift"}, "Page_Down", expand_vertical),
|
|
|
|
--▨ expand (neighbor)
|
2021-06-11 04:29:09 +02:00
|
|
|
|
2021-07-03 23:50:31 +02:00
|
|
|
awful.key({modkey}, "Insert", move_to("top-left")),
|
|
|
|
awful.key({modkey}, "Page_Up", move_to("top-right")),
|
|
|
|
awful.key({modkey}, "Delete", move_to("bottom-left")),
|
|
|
|
awful.key({modkey}, "Page_Down", move_to("bottom-right")),
|
|
|
|
--▨ move (positional)
|
2021-06-10 16:44:01 +02:00
|
|
|
|
2021-06-27 07:48:46 +02:00
|
|
|
awful.key({modkey}, "Home", expand_horizontal("center")),
|
|
|
|
awful.key({modkey}, "End", function()
|
|
|
|
client.focus.maximized_vertical = false
|
|
|
|
client.focus.maximized_horizontal = false
|
|
|
|
awful.client.floating.toggle()
|
2021-06-28 05:53:14 +02:00
|
|
|
end), --|toggle floating status
|
2021-06-11 01:14:42 +02:00
|
|
|
|
2021-07-03 23:50:31 +02:00
|
|
|
awful.key({modkey, "Shift"}, "End", toggle_always_on),
|
|
|
|
awful.key({modkey, "Shift"}, "Home", move_to("center")),
|
2021-06-10 20:41:12 +02:00
|
|
|
|
2021-07-03 23:50:31 +02:00
|
|
|
awful.key({modkey,}, "o", function ()
|
|
|
|
c = client.focus
|
|
|
|
if not c then return true end
|
2021-06-11 04:29:09 +02:00
|
|
|
|
2021-07-03 23:50:31 +02:00
|
|
|
if not c.floating then
|
|
|
|
c:geometry({width=300, height=300})
|
|
|
|
end --|to avoid machi's auto expansion
|
|
|
|
|
|
|
|
c:move_to_screen()
|
|
|
|
gears.timer.delayed_call(function ()
|
|
|
|
c:emit_signal("request::activate", "mouse_enter",{raise = true})
|
|
|
|
end)
|
|
|
|
end), --|client teleport to other screen
|
2021-06-11 01:14:42 +02:00
|
|
|
|
2021-07-03 23:50:31 +02:00
|
|
|
awful.key({modkey}, "Left", focus_by_direction("left")),
|
|
|
|
awful.key({modkey}, "Down", focus_by_direction("down")),
|
|
|
|
awful.key({modkey}, "Right", focus_by_direction("right")),
|
2021-06-27 07:48:46 +02:00
|
|
|
awful.key({modkey}, "Up", focus_by_direction("up")),
|
2021-06-28 05:53:14 +02:00
|
|
|
--▨ focus
|
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-07-03 23:50:31 +02:00
|
|
|
client.connect_signal("manage", function(c)
|
|
|
|
c.maximized = false
|
|
|
|
c.maximized_horizontal = false
|
|
|
|
c.maximized_vertical = false
|
|
|
|
end) --|during reload maximized clients get messed up, as machi
|
|
|
|
--|also tries to best fit the windows. this resets the
|
|
|
|
--|maximized state during a reload problem is with our hack
|
|
|
|
--|to use maximized, we should look into using machi
|
|
|
|
--|resize_handler instead
|
|
|
|
|
2021-06-27 07:48:46 +02:00
|
|
|
client.connect_signal("request::activate", function(c)
|
|
|
|
c.hidden = false
|
|
|
|
c:raise()
|
|
|
|
client.focus = c
|
2021-06-28 03:23:53 +02:00
|
|
|
end) --|this is needed to ensure floating stuff becomes
|
2021-06-28 13:27:03 +02:00
|
|
|
--|visible when invoked through run_or_raise.
|
2021-06-11 07:28:10 +02:00
|
|
|
|
2021-07-03 23:50:31 +02:00
|
|
|
client.connect_signal("focus", function(c)
|
|
|
|
if not (c.bypass or c.always_on) then
|
2021-06-27 07:48:46 +02:00
|
|
|
if not c.floating then
|
|
|
|
for _, tc in ipairs(screen[awful.screen.focused()].all_clients) do
|
2021-06-28 13:27:03 +02:00
|
|
|
if tc.floating and not tc.always_on then
|
2021-06-27 07:48:46 +02:00
|
|
|
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
|
2021-07-03 23:50:31 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
--[[+]
|
|
|
|
hide all floating windows when the user switches to a tiled
|
|
|
|
client. This is handy when you have a floating browser
|
|
|
|
open. Unless, client is set to always_on or bypass through
|
|
|
|
rules. ]]
|
|
|
|
|
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-07-03 23:50:31 +02:00
|
|
|
return setmetatable(module, { __call = function(_,...) return new({...}) end })
|