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

@ -224,49 +224,58 @@ local function expand_horizontal(direction)
if c.maximized_horizontal then if c.maximized_horizontal then
c.maximized_horizontal = false c.maximized_horizontal = false
end --| reset toggle maximized state end --|reset toggle maximized state
if c.direction == direction then if c.direction == direction then
c.direction = nil c.direction = nil
return return
end --| reset toggle when sending same shortcut end --|reset toggle when sending same shortcut
--| consequitively --|consequitively
local stuff = get_active_regions() local stuff = get_active_regions()
local target = grect.get_in_direction(direction, stuff.regions, client.focus:geometry()) local target = grect.get_in_direction(direction, stuff.regions, client.focus:geometry())
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
@ -284,16 +293,15 @@ local function expand_horizontal(direction)
client.focus:geometry(geom) client.focus:geometry(geom)
awful.placement.centered(client.focus) awful.placement.centered(client.focus)
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() -- ;
@ -304,25 +312,25 @@ local function expand_vertical()
if c.maximized_vertical then if c.maximized_vertical then
c.maximized_vertical = false c.maximized_vertical = false
return return
end --| reset toggle maximized state end --|reset toggle maximized state
local stuff = get_active_regions() local stuff = get_active_regions()
local target = grect.get_in_direction("down", stuff.regions, client.focus:geometry()) local target = grect.get_in_direction("down", stuff.regions, client.focus:geometry())
if target and stuff.regions[target].x ~= c.x then if target and stuff.regions[target].x ~= c.x then
return return
end --| flow control end --|flow control
--| ensure we are operating in the same X axis, --|ensure we are operating in the same X axis,
--| vertical directions jump around --|vertical directions jump around
if not target then if not target then
going = "up" going = "up"
target = grect.get_in_direction("up", stuff.regions, client.focus:geometry()) target = grect.get_in_direction("up", stuff.regions, client.focus:geometry())
end --| flow control end --|flow control
--| 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 = {
@ -358,15 +366,15 @@ local function shift_by_direction(direction, swap)
for i,c in ipairs(cltbl) do for i,c in ipairs(cltbl) do
if c.x == region.x and c.y == region.y then if c.x == region.x and c.y == region.y then
map[a] = i map[a] = i
break --| avoid stacked regions break --|avoid stacked regions
end end
end end
end --◸ end --◸
--| client list order we obtain via cltbl changes in --|client list order we obtain via cltbl changes in
--| each invokation, therfore we need to map the --|each invokation, therfore we need to map the
--| client table onto the region_list from machi. --|client table onto the region_list from machi.
--| this will give us the region numbers of clients. --|this will give us the region numbers of clients.
--| naughty.notify({text=inspect(map)}) --|naughty.notify({text=inspect(map)})
--◺ --◺
local target = grect.get_in_direction(direction, stuff.regions, client.focus:geometry()) local target = grect.get_in_direction(direction, stuff.regions, client.focus:geometry())
@ -382,12 +390,12 @@ local function shift_by_direction(direction, swap)
target = stuff.active_region - 1 target = stuff.active_region - 1
end end
end --◸ end --◸
--| we bumped into an edge, try to locate region via --|we bumped into an edge, try to locate region via
--| region_index and if that also fails, set back the --|region_index and if that also fails, set back the
--| previous region as target clock wise. --|previous region as target clock wise.
--| naughty.notify({text=inspect(target)}) --|naughty.notify({text=inspect(target)})
--| naughty.notify({text=inspect(map[target])}) --|naughty.notify({text=inspect(map[target])})
--| naughty.notify({text=inspect(cltbl[map[target]])}) --|naughty.notify({text=inspect(cltbl[map[target]])})
--◺ --◺
tobe = stuff.regions[target] tobe = stuff.regions[target]
@ -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())})
@ -421,7 +429,7 @@ local function shuffle(direction)
for i = #tablist, 1, -1 do for i = #tablist, 1, -1 do
prev_client = tablist[i] prev_client = tablist[i]
prev_client:emit_signal("request::activate", "mouse_enter",{raise = true}) prev_client:emit_signal("request::activate", "mouse_enter",{raise = true})
break --| activate previous client break --|activate previous client
end end
return return
end end
@ -434,7 +442,7 @@ local function shuffle(direction)
client.focus:lower() client.focus:lower()
next_client = tablist[_+1] next_client = tablist[_+1]
next_client:emit_signal("request::activate", "mouse_enter",{raise = true}) next_client:emit_signal("request::activate", "mouse_enter",{raise = true})
break --| activate next client break --|activate next client
end end
return return
end end
@ -454,11 +462,11 @@ local function my_shifter(direction)
next_region=stuff.regions[1] next_region=stuff.regions[1]
else else
next_region=stuff.regions[client_region+1] next_region=stuff.regions[client_region+1]
end --| figure out the action end --|figure out the action
if stuff.outofboundary then if stuff.outofboundary then
next_region=stuff.regions[client_region] next_region=stuff.regions[client_region]
end --| ignore action, and push inside the boundary instead end --|ignore action, and push inside the boundary instead
client.focus:geometry({ client.focus:geometry({
x=next_region.x, x=next_region.x,
@ -480,11 +488,11 @@ local function my_shifter(direction)
previous_region = stuff.regions[#stuff.regions] previous_region = stuff.regions[#stuff.regions]
else else
previous_region = stuff.regions[client_region-1] previous_region = stuff.regions[client_region-1]
end --| figure out the action end --|figure out the action
if stuff.outofboundary then if stuff.outofboundary then
previous_region = stuff.regions[client_region] previous_region = stuff.regions[client_region]
end --| ignore action, and push inside the boundary instead end --|ignore action, and push inside the boundary instead
client.focus:geometry({ client.focus:geometry({
x=previous_region.x, x=previous_region.x,