-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoggle_tile.lua
More file actions
53 lines (49 loc) · 1.32 KB
/
toggle_tile.lua
File metadata and controls
53 lines (49 loc) · 1.32 KB
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
local awful = require("awful")
local toggle = {}
local get_clients = function(screen)
local cs = {}
screen = screen or awful.screen.focused()
local tag = screen.selected_tag
if tag then
local tcs = tag:clients()
-- get all client use default client order
for _, c in ipairs(client.get()) do
for _, v in ipairs(tcs) do
if c == v then
table.insert(cs, v)
end
end
end
end
return cs
end
toggle.tile_or_floating = function(screen)
screen = screen or awful.screen.focused()
local tag = screen.selected_tag
if tag and tag.layout.name ~= awful.layout.suit.tile.name then
tag.layout = awful.layout.suit.tile
for _, client in ipairs(get_clients()) do
client.floating = false
client.maximized = false
end
elseif tag and tag.layout.name ~= awful.layout.suit.floating.name then
tag.layout = awful.layout.suit.floating
for _, client in ipairs(get_clients()) do
client.floating = true
client.maximized = true
end
end
end
toggle.focus = function(index)
local screen = awful.screen.focused()
if not screen then return end
local c = get_clients(screen)[index]
if c and client.focus and client.focus ~= c then
if client.minimized then
client.minimized = false
end
client.focus = c
c:raise()
end
end
return toggle