This repository was archived by the owner on Oct 31, 2023. It is now read-only.
forked from material-shell/material-awesome
-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathquake-terminal.lua
112 lines (103 loc) · 2.28 KB
/
quake-terminal.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
local awful = require('awful')
local ruled = require('ruled')
local beautiful = require('beautiful')
local app = require('configuration.apps').default.quake
local client_keys = require('configuration.client.keys')
local client_buttons = require('configuration.client.buttons')
local quake_id = nil
local quake_client = nil
local quake_opened = false
local quake_properties = function()
return {
skip_decoration = true,
titlebars_enabled = false,
switch_to_tags = true,
opacity = 0.95,
floating = true,
skip_taskbar = true,
ontop = true,
above = true,
sticky = true,
hidden = not quake_opened,
maximized_horizontal = true,
skip_center = true,
round_corners = false,
keys = client_keys,
buttons = client_buttons,
placement = awful.placement.top,
shape = beautiful.client_shape_rectangle
}
end
ruled.client.connect_signal(
'request::rules',
function()
ruled.client.append_rule {
id = 'quake_terminal',
rule_any = {
instance = {
'QuakeTerminal'
}
},
properties = quake_properties()
}
end
)
local create_quake = function()
-- Check if there's already an instance of 'QuakeTerminal'.
-- If yes, recover it - use it again.
local quake_term = function (c)
return ruled.client.match(c, {instance = 'QuakeTerminal'})
end
for c in awful.client.iterate(quake_term) do
-- 'QuakeTerminal' instance detected
-- Re-apply its properties
ruled.client.execute(c, quake_properties())
quake_id = c.pid
c:emit_signal('request::activate')
return
end
-- No 'QuakeTerminal' instance, spawn one
quake_id = awful.spawn(app, quake_properties())
end
local quake_open = function()
quake_client.hidden = false
quake_client:emit_signal('request::activate')
end
local quake_close = function()
quake_client.hidden = true
end
local quake_toggle = function()
quake_opened = not quake_opened
if not quake_client then
create_quake()
else
if quake_opened then
quake_open()
else
quake_close()
end
end
end
awesome.connect_signal(
'module::quake_terminal:toggle',
function()
quake_toggle();
end
)
client.connect_signal(
'manage',
function(c)
if c.pid == quake_id then
quake_client = c
end
end
)
client.connect_signal(
'unmanage',
function(c)
if c.pid == quake_id then
quake_opened = false
quake_client = nil
end
end
)