- -- First, we locate the client
- local client = nil
- local i = 0
- for c in awful.client.iterate(function (c)
- -- c.name may be changed!
- return c.instance == self.name
- end, nil, self.screen)
- do
- i = i + 1
- if i == 1 then
- client = c
- else
- -- Additional matching clients, let's remove the sticky bit
- -- which may persist between awesome restarts. We don't close
- -- them as they may be valuable. They will just turn into
- -- normal clients.
- c.sticky = false
- c.ontop = false
- c.above = false
- end
- end
-
- if not client and not self.visible then return end
-
- if not client then
- -- The client does not exist, we spawn it
- awful.util.spawn(string.format("%s %s %s", self.app,
- string.format(self.argname, self.name), self.extra),
- false, self.screen)
- self.notexist = true
- return
- end
-
- -- Resize
- awful.client.floating.set(client, true)
- client.border_width = self.border
- client.size_hints_honor = false
- if self.notexist then
- self:compute_size()
- client:geometry(self.geometry)
- self.notexist = false
- end
-
- -- Not sticky and on top
- client.sticky = false
- client.ontop = true
- client.above = true
- client.skip_taskbar = true
-
- -- Toggle display
- if self.visible then
- client.hidden = false
- client:raise()
- self.last_tag = awful.tag.selected(self.screen)
- client:tags({awful.tag.selected(self.screen)})
- capi.client.focus = client
+ if self.followtag then self.screen = awful.screen.focused() end
+
+ -- First, we locate the client
+ local client = nil
+ local i = 0
+ for c in awful.client.iterate(function (c)
+ -- c.name may be changed!
+ return c.instance == self.name
+ end)
+ do
+ i = i + 1
+ if i == 1 then
+ client = c
+ else
+ -- Additional matching clients, let's remove the sticky bit
+ -- which may persist between awesome restarts. We don't close
+ -- them as they may be valuable. They will just turn into
+ -- normal clients.
+ c.sticky = false
+ c.ontop = false
+ c.above = false
+ end
+ end
+
+ if not client and not self.visible then return end
+
+ if not client then
+ -- The client does not exist, we spawn it
+ cmd = string.format("%s %s %s", self.app,
+ string.format(self.argname, self.name), self.extra)
+ awful.spawn(cmd, { tag = self.screen.selected_tag })
+ return
+ end
+
+ -- Set geometry
+ client.floating = true
+ client.border_width = self.border
+ client.size_hints_honor = false
+ client:geometry(self.geometry[self.screen.index] or self:compute_size())
+
+ -- Set not sticky and on top
+ client.sticky = false
+ client.ontop = true
+ client.above = true
+ client.skip_taskbar = true
+
+ -- Additional user settings
+ if self.settings then self.settings(client) end
+
+ -- Toggle display
+ if self.visible then
+ client.hidden = false
+ client:raise()
+ self.last_tag = self.screen.selected_tag
+ client:tags({self.screen.selected_tag})
+ client.focus = client