All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 Licensed under GNU General Public License v2
5 * (c) 2016, Luke Bonham
9 local awful = require("awful")
10 local capi = { client = client,
13 timer = timer or require("gears.timer") }
14 local math = { floor = math.floor }
18 local setmetatable = setmetatable
19 local tostring = tostring
21 -- Quake-like Dropdown application spawn
22 -- Original version: https://awesomewm.org/wiki/Drop-down_terminal#Another_solution
25 -- If you have a rule like "awful.client.setslave" for your terminals,
26 -- ensure you use an exception for QuakeDD. Otherwise, you may
27 -- run into problems with focus.
29 function quake:display()
30 -- First, we locate the client
33 for c in awful.client.iterate(function (c)
34 -- c.name may be changed!
35 return c.instance == self.name
36 end, nil, self.screen)
42 -- Additional matching clients, let's remove the sticky bit
43 -- which may persist between awesome restarts. We don't close
44 -- them as they may be valuable. They will just turn into
52 if not client and not self.visible then return end
55 -- The client does not exist, we spawn it
56 awful.util.spawn(string.format("%s %s %s", self.app,
57 string.format(self.argname, self.name), self.extra),
64 awful.client.floating.set(client, true)
65 client.border_width = self.border
66 client.size_hints_honor = false
68 client:geometry(self.geometry)
72 -- Not sticky and on top
75 client.skip_taskbar = true
82 self.last_tag = tostring(awful.tag.selected(self.screen))
83 client:tags({awful.tag.selected(self.screen)})
84 capi.client.focus = client
87 local ctags = client:tags()
88 for i, t in pairs(ctags) do
97 function quake:new(config)
98 local conf = config or {}
100 conf.app = conf.app or "xterm" -- application to spawn
101 conf.name = conf.name or "QuakeDD" -- window name
102 conf.argname = conf.argname or "-name %s" -- how to specify window name
103 conf.extra = conf.extra or "" -- extra arguments
104 conf.visible = conf.visible or false -- initially not visible
105 conf.screen = conf.screen or capi.mouse.screen
106 conf.border = conf.border or 1
108 -- If width or height <= 1 this is a proportion of the workspace
109 wibox_height = conf.wibox_height or 18 -- statusbar weight
110 height = conf.height or 0.25 -- height
111 width = conf.width or 1 -- width
112 vert = conf.vert or "top" -- top, bottom or center
113 horiz = conf.horiz or "center" -- left, right or center
116 local geom = capi.screen[conf.screen].workarea
117 if width <= 1 then width = math.floor(geom.width * width) end
118 if height <= 1 then height = math.floor(geom.height * height) end
120 if horiz == "left" then x = geom.x
121 elseif horiz == "right" then x = geom.width + geom.x - width
122 else x = geom.x + (geom.width - width)/2 end
123 if vert == "top" then y = geom.y
124 elseif vert == "bottom" then y = geom.height + geom.y - height
125 else y = geom.y + (geom.height - height)/2 end
126 conf.geometry = { x = x, y = y + wibox_height, width = width, height = height }
128 local console = setmetatable(conf, { __index = quake })
129 capi.client.connect_signal("manage", function(c)
130 if c.instance == console.name and c.screen == console.screen then
134 capi.client.connect_signal("unmanage", function(c)
135 if c.instance == console.name and c.screen == console.screen then
136 console.visible = false
140 -- "Reattach" currently running quake application. This is in case awesome is restarted.
141 local reattach = capi.timer { timeout = 0 }
142 reattach:connect_signal("timeout", function()
151 function quake:toggle()
152 current_tag = awful.tag.selected(self.screen)
153 if self.last_tag ~= tostring(current_tag) and self.visible then
154 awful.client.movetotag(current_tag, self:display())
156 self.visible = not self.visible
161 setmetatable(quake, { __call = function(_, ...) return quake:new(...) end })