This commit is contained in:
anakha 2021-06-27 21:23:53 -04:00
parent a4c0ec22d2
commit 5b79c5f181
2 changed files with 90 additions and 79 deletions

View File

@ -1,5 +1,8 @@
---------------------------------------------------------- dependencies -- ; ---------------------------------------------------------- dependencies -- ;
-- local chainbind = require("chainbind")
local capi = {root=root} local capi = {root=root}
local gears = require("gears") local gears = require("gears")
local naughty = require("naughty") local naughty = require("naughty")
@ -24,78 +27,78 @@ local expand_vertical = machina.expand_vertical
local bindings = { local bindings = {
----------------╮ ----------------╮
--│ SHUFFLE ◊◊ --▨ SHUFFLE ▨
----------------╯ ----------------╯
awful.key({modkey}, ";", shuffle("backward")),
--|shuffle region backward
awful.key({modkey}, "'", shuffle("forward")),
--|shuffle regions forward
awful.key({modkey, "Shift"}, "j", shift_by_direction("left")), awful.key({modkey, "Shift"}, "j", shift_by_direction("left")),
--+ move client to left --|move client to left
awful.key({modkey, "Shift"}, "l", shift_by_direction("right")), awful.key({modkey, "Shift"}, "l", shift_by_direction("right")),
--+ move client to right --|move client to right
awful.key({modkey, "Shift"}, "k", shift_by_direction("down")), awful.key({modkey, "Shift"}, "k", shift_by_direction("down")),
--+ move client to down --|move client to down
awful.key({modkey, "Shift"}, "i", shift_by_direction("up")), awful.key({modkey, "Shift"}, "i", shift_by_direction("up")),
--+ move client to down --|move client to down
awful.key({modkey}, ";", shift_by_direction("left", true)),
--+ swap left
awful.key({modkey}, "'", shift_by_direction("right", true)),
--+ swap right
awful.key({modkey}, "[", my_shifter("backward")), awful.key({modkey}, "[", my_shifter("backward")),
--+ custom shift client logic --|custom shift client logic
awful.key({modkey}, "]", my_shifter("forward")), awful.key({modkey}, "]", my_shifter("forward")),
--+ custom shift client logic --|custom shift client logic
awful.key({modkey, "Shift"}, "[", shuffle("backward")), awful.key({modkey, "Shift"}, "[", shift_by_direction("left", true)),
--+ shuffle region backward --|swap left
awful.key({modkey, "Shift"}, "]", shuffle("forward")), awful.key({modkey, "Shift"}, "]", shift_by_direction("right", true)),
--+ shuffle regions forward --|swap right
----------------╮ ----------------╮
--│ PLACEMENT ◊◊ --▨ PLACEMENT ▨
----------------╯ ----------------╯
awful.key({modkey}, "Insert", expand_horizontal("left")), awful.key({modkey}, "Insert", expand_horizontal("left")),
--+ expand to right --|expand to right
awful.key({modkey}, "Page_Up", expand_horizontal("right")), awful.key({modkey}, "Page_Up", expand_horizontal("right")),
--+ expand to left --|expand to left
awful.key({modkey}, "Home", expand_horizontal("center")), awful.key({modkey}, "Home", expand_horizontal("center")),
--+ expand to center as float --|expand to center as float
awful.key({modkey}, "End", function() awful.key({modkey}, "End", function()
client.focus.maximized_vertical = false client.focus.maximized_vertical = false
client.focus.maximized_horizontal = false client.focus.maximized_horizontal = false
awful.client.floating.toggle() awful.client.floating.toggle()
end), end),
--+ toggle floating status --|toggle floating status
awful.key({modkey}, "Page_Down", expand_vertical), awful.key({modkey}, "Page_Down", expand_vertical),
--+ expand vertical --|expand vertical
----------------╮ ----------------╮
--│ FOCUS ◊◊ --▨ FOCUS ▨
----------------╯ ----------------╯
awful.key({modkey}, "Left", focus_by_direction("left")), awful.key({modkey}, "Left", focus_by_direction("left")),
awful.key({modkey}, "j", focus_by_direction("left")), awful.key({modkey}, "j", focus_by_direction("left")),
--+ stack friendly focus left --|stack friendly focus left
awful.key({modkey}, "Down", focus_by_direction("down")), awful.key({modkey}, "Down", focus_by_direction("down")),
awful.key({modkey}, "k", focus_by_direction("down")), awful.key({modkey}, "k", focus_by_direction("down")),
--+ stack friendly focus down --|stack friendly focus down
awful.key({modkey}, "Right", focus_by_direction("right")), awful.key({modkey}, "Right", focus_by_direction("right")),
awful.key({modkey}, "l", focus_by_direction("right")), awful.key({modkey}, "l", focus_by_direction("right")),
--+ stack friendly focus right --|stack friendly focus right
awful.key({modkey}, "Up", focus_by_direction("up")), awful.key({modkey}, "Up", focus_by_direction("up")),
awful.key({modkey}, "i", focus_by_direction("up")) awful.key({modkey}, "i", focus_by_direction("up"))
--+ stack friendly focus up --|stack friendly focus up
} }
@ -105,8 +108,8 @@ client.connect_signal("request::activate", function(c)
c.hidden = false c.hidden = false
c:raise() c:raise()
client.focus = c client.focus = c
end) ----| this is needed to ensure floating stuff becomes end) --|this is needed to ensure floating stuff becomes
----| visible when invoked through run_or_raise --|visible when invoked through run_or_raise
client.connect_signal("focus", function(c) client.connect_signal("focus", function(c)
if not c.floating then if not c.floating then
@ -126,9 +129,9 @@ client.connect_signal("focus", function(c)
end end
return return
end end
end) ----| hide all floating windows when the user switches to a end) --|hide all floating windows when the user switches to a
----| tiled client. this is handy when you have a floating --|tiled client. this is handy when you have a floating
----| browser open. --|browser open.
--------------------------------------------------------------- exports -- ; --------------------------------------------------------------- exports -- ;

View File

@ -237,36 +237,45 @@ local function expand_horizontal(direction)
if not target and direction ~= "center" then return end -- flow control if not target and direction ~= "center" then return end -- flow control
--▨▨▨
if direction == "right" then if direction == "right" then
tobe = { tobe = {
x=c.x, x=c.x,
width=stuff.regions[target].x + stuff.regions[target].width - c.x width=math.abs(stuff.regions[target].x + stuff.regions[target].width - c.x),
height=c.height,
y=c.y
} }
naughty.notify({text=inspect(stuff.regions[target])})
c.direction = direction c.direction = direction
c.maximized_horizontal = true c.maximized_horizontal = true
c.maximixed_vertical = false c.maximixed_vertical = false
c.width = tobe.width
c.x = tobe.x gears.timer.delayed_call(function ()
c:raise() client.focus:geometry(tobe)
end)
return return
end end
--▨▨▨
if direction == "left" then if direction == "left" then
tobe = { tobe = {
x=stuff.regions[target].x, x=stuff.regions[target].x,
width=c.x + c.width - stuff.regions[target].x width=c.x + c.width - stuff.regions[target].x,
height=c.height,
y=c.y
} }
c.direction = direction c.direction = direction
c.maximized_horizontal = true c.maximized_horizontal = true
c.maximixed_vertical = false c.maximixed_vertical = false
c.width = tobe.width
c.x = tobe.x gears.timer.delayed_call(function ()
c:raise() client.focus:geometry(tobe)
end)
return return
end end
--▨▨▨
if direction == "center" then if direction == "center" then
c.maximized = false c.maximized = false
c.maximixed_vertical = false c.maximixed_vertical = false
@ -286,14 +295,13 @@ local function expand_horizontal(direction)
client.focus:raise() client.focus:raise()
end) --|give it time in case maximize_horizontal is end) --|give it time in case maximize_horizontal is
--|adjusted before centering --|adjusted before centering
return return
end end
end end
end end
-- c.direction is used to create a fake toggling effect. --|c.direction is used to create a fake toggling effect.
-- tiled clients require an internal maximized property to --|tiled clients require an internal maximized property to
-- be set, otherwise they won't budge. --|be set, otherwise they won't budge.
----------------------------------------------------- expand_vertical() -- ; ----------------------------------------------------- expand_vertical() -- ;
@ -322,7 +330,7 @@ local function expand_vertical()
--|try reverse direction --|try reverse direction
if not target then return end if not target then return end
-- flow control --|flow control
if going == "down" then if going == "down" then
tobe = { tobe = {
@ -395,14 +403,14 @@ local function shift_by_direction(direction, swap)
client.focus:geometry(tobe) client.focus:geometry(tobe)
client.focus:raise() client.focus:raise()
-- relocate --|relocate
swapee = cltbl[map[target]] swapee = cltbl[map[target]]
-- try to get client at target region --|try to get client at target region
if swap and swapee then if swap and swapee then
swapee:geometry(is) swapee:geometry(is)
swapee:raise() swapee:emit_signal("request::activate", "mouse_enter",{raise = true})
end end
-- naughty.notify({text=inspect(cltbl[2]:geometry())}) -- naughty.notify({text=inspect(cltbl[2]:geometry())})