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-07-11 22:34:28 +02:00
|
|
|
local naughty = require('naughty')
|
|
|
|
local gears = require("gears")
|
2021-06-10 16:28:28 +02:00
|
|
|
local awful = require("awful")
|
2021-07-11 22:34:28 +02:00
|
|
|
local beautiful = require('beautiful')
|
2021-06-10 16:28:28 +02:00
|
|
|
local modkey = "Mod4"
|
2021-07-07 05:02:58 +02:00
|
|
|
local altkey = "Mod1"
|
2021-06-10 16:28:28 +02:00
|
|
|
|
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-07-05 06:34:14 +02:00
|
|
|
local teleport_client = machina.teleport_client
|
2021-07-07 05:02:58 +02:00
|
|
|
local get_client_info = machina.get_client_info
|
2021-07-08 09:08:40 +02:00
|
|
|
local focus_by_index = machina.focus_by_index
|
|
|
|
local focus_by_number = machina.focus_by_number
|
2021-07-10 02:27:14 +02:00
|
|
|
local set_region = machina.set_region
|
|
|
|
local align_floats = machina.align_floats
|
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-08 09:08:40 +02:00
|
|
|
awful.key({altkey},"Tab", shuffle("backward")),
|
2021-07-07 05:02:58 +02:00
|
|
|
awful.key({altkey, "Shift"}, "Tab", shuffle("forward")),
|
2021-07-08 09:08:40 +02:00
|
|
|
|
|
|
|
-- awful.key({modkey}, "#10", focus_by_number(1)),
|
|
|
|
-- awful.key({modkey}, "#11", focus_by_number(2)),
|
|
|
|
-- awful.key({modkey}, "#12", focus_by_number(3)),
|
|
|
|
-- awful.key({modkey}, "#13", focus_by_number(4)),
|
|
|
|
-- awful.key({modkey}, "#14", focus_by_number(5)),
|
2021-07-07 05:02:58 +02:00
|
|
|
|
2021-07-05 02:44:09 +02:00
|
|
|
awful.key({modkey}, "[", shuffle("backward")),
|
|
|
|
awful.key({modkey}, "]", shuffle("forward")),
|
2021-07-08 09:08:40 +02:00
|
|
|
--▨ move
|
|
|
|
|
|
|
|
-- awful.key({modkey}, "Tab", focus_by_index("backward")),
|
|
|
|
-- awful.key({modkey, "Shift"}, "Tab", focus_by_index("forward")),
|
2021-07-10 02:27:14 +02:00
|
|
|
|
|
|
|
awful.key({modkey}, ";", align_floats("right")),
|
|
|
|
awful.key({modkey, "Shift"}, ";", align_floats("left")),
|
2021-07-10 02:49:27 +02:00
|
|
|
--▨ alignment
|
2021-07-07 05:02:58 +02:00
|
|
|
|
|
|
|
awful.key({modkey}, "x", function ()
|
|
|
|
c = client.focus or nil
|
|
|
|
if not c then return end
|
|
|
|
if c.floating then c.minimized = true return end
|
|
|
|
shuffle("backward")(c)
|
|
|
|
end),
|
|
|
|
|
|
|
|
awful.key({modkey, "Shift"}, "x", function ()
|
|
|
|
c = client.focus or nil
|
|
|
|
if not c then return end
|
|
|
|
if c.floating then c.minimized = true return end
|
|
|
|
shuffle("forward")(c)
|
|
|
|
end),
|
2021-07-05 02:44:09 +02:00
|
|
|
--▨ shuffle
|
|
|
|
|
|
|
|
awful.key({modkey, "Shift"}, "[", my_shifter("backward")),
|
|
|
|
awful.key({modkey, "Shift"}, "]", my_shifter("forward")),
|
2021-07-03 23:50:31 +02:00
|
|
|
--▨ move
|
|
|
|
|
2021-07-05 02:44:09 +02:00
|
|
|
awful.key({modkey, "Control"}, "[", my_shifter("backward", "swap")),
|
|
|
|
awful.key({modkey, "Control"}, "]", my_shifter("forward", "swap")),
|
2021-07-03 23:50:31 +02:00
|
|
|
--▨ swap
|
|
|
|
|
2021-07-22 07:52:31 +02:00
|
|
|
awful.key({modkey}, "'", function ()
|
2021-07-22 15:04:22 +02:00
|
|
|
naughty.notify({text=inspect(client.focus.transient_for)})
|
2021-07-22 07:52:31 +02:00
|
|
|
end),
|
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}, "Insert", move_to("top-left")),
|
|
|
|
awful.key({modkey}, "Delete", move_to("bottom-left")),
|
2021-07-07 21:52:05 +02:00
|
|
|
awful.key({modkey}, "u", expand_horizontal("center")),
|
2021-07-06 00:54:27 +02:00
|
|
|
awful.key({modkey}, "Home", expand_horizontal("center")),
|
|
|
|
awful.key({modkey}, "Page_Up", move_to("top-right")),
|
2021-07-03 23:50:31 +02:00
|
|
|
awful.key({modkey}, "Page_Down", move_to("bottom-right")),
|
|
|
|
--▨ move (positional)
|
2021-06-10 16:44:01 +02:00
|
|
|
|
2021-07-06 00:54:27 +02:00
|
|
|
awful.key({modkey, "Shift"}, "Insert", expand_horizontal("left")),
|
|
|
|
awful.key({modkey, "Shift"}, "End", toggle_always_on),
|
|
|
|
awful.key({modkey, "Shift"}, "Home", move_to("center")),
|
|
|
|
awful.key({modkey, "Shift"}, "Page_Up", expand_horizontal("right")),
|
|
|
|
awful.key({modkey, "Shift"}, "Page_Down", expand_vertical),
|
|
|
|
--▨ expand (neighbor)
|
|
|
|
|
2021-07-06 17:20:47 +02:00
|
|
|
awful.key({modkey}, "End", function(c)
|
2021-06-27 07:48:46 +02:00
|
|
|
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}, "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-07-06 00:54:27 +02:00
|
|
|
|
|
|
|
awful.key({modkey,}, "o", teleport_client), --|client teleport to other screen
|
|
|
|
|
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-13 20:44:01 +02:00
|
|
|
tag.connect_signal("property::selected", function(t)
|
|
|
|
if client.focus == nil then
|
|
|
|
local s = awful.screen.focused()
|
|
|
|
client.focus = awful.client.focus.history.get(s, 0)
|
|
|
|
end
|
|
|
|
end) --|ensure there is always a selected client during tag
|
|
|
|
--|switching or logins
|
|
|
|
|
|
|
|
|
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
|
2021-07-22 07:52:31 +02:00
|
|
|
-- c.minimized = false
|
2021-06-27 07:48:46 +02:00
|
|
|
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
|
2021-07-22 07:52:31 +02:00
|
|
|
end)
|
2021-07-03 23:50:31 +02:00
|
|
|
--[[+]
|
|
|
|
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 })
|