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,
17 local setmetatable = setmetatable
18 local tostring = tostring
20 -- Quake-like Dropdown application spawn
21 -- Original version: https://awesomewm.org/wiki/Drop-down_terminal#Another_solution
24 -- If you have a rule like "awful.client.setslave" for your terminals,
25 -- ensure you use an exception for QuakeDD. Otherwise, you may
26 -- run into problems with focus.
28 function quake:display()
29 -- First, we locate the client
32 for c in awful.client.iterate(function (c)
33 -- c.name may be changed!
34 return c.instance == self.name
35 end, nil, self.screen)
41 -- Additional matching clients, let's remove the sticky bit
42 -- which may persist between awesome restarts. We don't close
43 -- them as they may be valuable. They will just turn into
51 if not client and not self.visible then return end
54 -- The client does not exist, we spawn it
55 awful.util.spawn(self.app .. " " .. string.format(self.argname, self.name),
61 awful.client.floating.set(client, true)
62 client.border_width = 0
63 client.size_hints_honor = false
64 client:geometry(self.geometry)
66 -- Not sticky and on top
69 client.skip_taskbar = true
76 self.last_tag = tostring(awful.tag.selected(self.screen))
77 client:tags({awful.tag.selected(self.screen)})
78 capi.client.focus = client
81 local ctags = client:tags()
82 for i, t in pairs(ctags) do
91 function quake:new(config)
92 local conf = config or {}
94 conf.app = conf.app or "xterm" -- application to spawn
95 conf.name = conf.name or "QuakeDD" -- window name
96 conf.argname = conf.argname or "-name %s" -- how to specify window name
97 conf.visible = conf.visible or false -- initially not visible
98 conf.screen = conf.screen or capi.mouse.screen
100 -- If width or height <= 1 this is a proportion of the workspace
101 wibox_height = conf.wibox_height or 18 -- statusbar weight
102 height = conf.height or 0.25 -- height
103 width = conf.width or 1 -- width
104 vert = conf.vert or "top" -- top, bottom or center
105 horiz = conf.horiz or "center" -- left, right or center
108 local geom = capi.screen[conf.screen].workarea
109 if width <= 1 then width = geom.width * width end
110 if height <= 1 then height = geom.height * height end
112 if horiz == "left" then x = geom.x
113 elseif horiz == "right" then x = geom.width + geom.x - width
114 else x = geom.x + (geom.width - width)/2 end
115 if vert == "top" then y = geom.y
116 elseif vert == "bottom" then y = geom.height + geom.y - height
117 else y = geom.y + (geom.height - height)/2 end
118 conf.geometry = { x = x, y = y + wibox_height, width = width, height = height }
120 local console = setmetatable(conf, { __index = quake })
121 capi.client.connect_signal("manage", function(c)
122 if c.instance == console.name and c.screen == console.screen then
126 capi.client.connect_signal("unmanage", function(c)
127 if c.instance == console.name and c.screen == console.screen then
128 console.visible = false
132 -- "Reattach" currently running quake application. This is in case awesome is restarted.
133 local reattach = capi.timer { timeout = 0 }
134 reattach:connect_signal("timeout", function()
143 function quake:toggle()
144 current_tag = awful.tag.selected(self.screen)
145 if self.last_tag ~= tostring(current_tag) and self.visible then
146 awful.client.movetotag(current_tag, self:display())
148 self.visible = not self.visible
153 setmetatable(quake, { __call = function(_, ...) return quake:new(...) end })