-
Notifications
You must be signed in to change notification settings - Fork 0
/
dropdown.lua
88 lines (75 loc) · 1.85 KB
/
dropdown.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
local drop = {
enabled = false,
startup = true,
}
function drop.onoff()
local globalkeys = root.keys()
hasitem = gears.table.hasitem
if drop.enabled then
rout("Drop terminals Off", 1)
globalkeys = filter_table(globalkeys, function(x)
return (x.key == "F1" or
x.key == "F2" or
x.key == "F3" or
x.key == "F4")
and not hasitem(x.modifiers, Win)
end)
else
rout("Drop terminals On", 1)
globalkeys = gears.table.join(globalkeys,
awful.key({ }, "F1", function () drop.toggle(1) end ),
awful.key({ }, "F2", function () drop.toggle(2) end ),
awful.key({ }, "F3", function ()
toggle_hidden("instance", "claws-mail", "evolution", "Mail")
end),
awful.key({ }, "F4", function ()
toggle_hidden("instance", "Telegram", "telegram-desktop", "skype")
end))
end
drop.enabled = not drop.enabled
root.keys(globalkeys)
end
function drop.setprop(c, n, resize)
area = awful.screen.focused().geometry
yy = area.y
xx = area.x + (area.width - c:geometry().width)/2
ww = 800
hh = 300
if n == 2 then
yy = yy + area.height - c:geometry().height - 2
elseif n == 3 then
xx = area.x
ww = area.width / 2
hh = area.height - 2
end
if resize then
c:geometry({ width = ww, height = hh, y = yy, x = xx})
else
c:geometry({ y = yy, x = xx})
end
-- Only hide if it already exists when awesome just started
c.hidden = drop.startup
end
function drop.toggle(n)
drop.startup = false
local c = getclient("instance", "dropterm"..n)
if not c then
if n == 3 then
awful.spawn(terminal.." -name dropterm"..n.." -e su")
else
awful.spawn(terminal.." -name dropterm"..n)
end
elseif c.hidden then
drop.setprop(c, n, false)
client.focus = c
c:raise()
else
if c ~= client.focus then
client.focus = c
else
c.hidden = true
end
end
end
return drop
-- vim:ts=4:sw=4