-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.lua
197 lines (162 loc) · 6.73 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
---------------------------------------------------------- dependencies -- ;
local capi = {root=root}
local naughty = require('naughty')
local gears = require("gears")
local awful = require("awful")
local beautiful = require('beautiful')
local modkey = "Mod4"
local altkey = "Mod1"
local machina = require("machina.methods")
local backham = require("machina.backham")
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
local move_to = machina.move_to
local toggle_always_on = machina.toggle_always_on
local teleport_client = machina.teleport_client
local get_client_info = machina.get_client_info
local focus_by_index = machina.focus_by_index
local focus_by_number = machina.focus_by_number
local set_region = machina.set_region
local align_floats = machina.align_floats
---------------------------------------------------------- key bindings -- ;
local bindings = {
awful.key({altkey},"Tab", shuffle("backward")),
awful.key({altkey, "Shift"}, "Tab", shuffle("forward")),
-- 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)),
awful.key({modkey}, "[", shuffle("backward")),
awful.key({modkey}, "]", shuffle("forward")),
--▨ move
-- awful.key({modkey}, "Tab", focus_by_index("backward")),
-- awful.key({modkey, "Shift"}, "Tab", focus_by_index("forward")),
awful.key({modkey}, ";", align_floats("right")),
awful.key({modkey, "Shift"}, ";", align_floats("left")),
--▨ alignment
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),
--▨ shuffle
awful.key({modkey, "Shift"}, "[", my_shifter("backward")),
awful.key({modkey, "Shift"}, "]", my_shifter("forward")),
--▨ move
awful.key({modkey, "Control"}, "[", my_shifter("backward", "swap")),
awful.key({modkey, "Control"}, "]", my_shifter("forward", "swap")),
--▨ swap
awful.key({modkey}, "'", function ()
naughty.notify({text=inspect(client.focus.transient_for)})
end),
--▨ 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
awful.key({modkey, "Shift"}, "j", shift_by_direction("left")),
awful.key({modkey, "Shift"}, "l", shift_by_direction("right")),
awful.key({modkey, "Shift"}, "k", shift_by_direction("down")),
awful.key({modkey, "Shift"}, "i", shift_by_direction("up")),
--▨ move
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
awful.key({modkey}, "Insert", move_to("top-left")),
awful.key({modkey}, "Delete", move_to("bottom-left")),
awful.key({modkey}, "u", expand_horizontal("center")),
awful.key({modkey}, "Home", expand_horizontal("center")),
awful.key({modkey}, "Page_Up", move_to("top-right")),
awful.key({modkey}, "Page_Down", move_to("bottom-right")),
--▨ move (positional)
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)
awful.key({modkey}, "End", function(c)
client.focus.maximized_vertical = false
client.focus.maximized_horizontal = false
awful.client.floating.toggle()
end), --|toggle floating status
awful.key({modkey}, "Left", focus_by_direction("left")),
awful.key({modkey}, "Down", focus_by_direction("down")),
awful.key({modkey}, "Right", focus_by_direction("right")),
awful.key({modkey}, "Up", focus_by_direction("up")),
--▨ focus
awful.key({modkey,}, "o", teleport_client), --|client teleport to other screen
}
--------------------------------------------------------------- signals -- ;
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
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
client.connect_signal("request::activate", function(c)
c.hidden = false
-- c.minimized = false
c:raise()
client.focus = c
end) --|this is needed to ensure floating stuff becomes
--|visible when invoked through run_or_raise.
client.connect_signal("focus", function(c)
if not (c.bypass or c.always_on) then
if not c.floating then
for _, tc in ipairs(screen[awful.screen.focused()].all_clients) do
if tc.floating and not tc.always_on then
tc.hidden = true
end
end
return
end
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
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. ]]
--------------------------------------------------------------- exports -- ;
module = {
bindings = bindings
}
local function new(arg)
capi.root.keys(awful.util.table.join(capi.root.keys(), table.unpack(bindings)))
return module
end
return setmetatable(module, { __call = function(_,...) return new({...}) end })