blob: aa1fd1e16b1052c38943097ea1b51851b5cb3000 (
plain) (
blame)
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
|
local client = client
local awful = require("awful")
local util = require("awful.util")
local scratch = {}
local function activate(c)
local ctag = awful.tag.selected(c.screen)
ctags = {ctag}
for k,tag in pairs(c:tags()) do
if tag ~= ctag then table.insert(ctags, tag) end
end
c:tags(ctags)
c:raise()
client.focus = c
end
local function deactivate(c)
local ctag = awful.tag.selected(c.screen)
ctags = {}
for k,tag in pairs(c:tags()) do
if tag ~= ctag then table.insert(ctags, tag) end
end
c:tags(ctags)
end
function scratch.raise(cmd, rule)
local rule = rule or { instance = "scratch" }
local function match(c) return awful.rules.match(c, rule) end
local clients = client.get()
local findex = util.table.hasitem(clients, client.focus) or 1
local start = util.cycle(#clients, findex + 1)
for c in awful.client.iterate(match, start) do
activate(c)
return
end
util.spawn(cmd)
end
function scratch.toggle(cmd, rule)
local rule = rule or { instance = "scratch" }
if client.focus and awful.rules.match(client.focus, rule) then
deactivate(client.focus)
else
scratch.raise(cmd)
end
end
return scratch
|