blob: 7cc5df1472d43067e8ea47ec4ab251f08c307a22 (
plain)
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
|
local awful = awful
local beautiful = beautiful
local client = client
local ext = require("ext")
local lfs = require("lfs")
local pairs = pairs
local string = string
local table = table
local widget = widget
module("oni")
local maildirfmt = "/home/slash/documents/mail/%s/inbox/new/"
function mailcount(account)
local i = 0
local dir = string.format(maildirfmt, account)
for file in lfs.dir(dir) do
if file ~= "." and file ~= ".." then
i = i + 1
end
end
return i
end
local function showmail(name)
awful.util.spawn("emacsclient -e '(oni:view-mail \"" .. name .. "\")'")
end
function mailcount_widgets(label, account, name)
widgets = {}
widgets.label = widget({ type = "textbox" })
widgets.label.text = string.format(" %s: ", label)
widgets.count = widget({ type = "textbox" })
widgets.count.text = string.format(" %d ", mailcount(account))
widgets.count.bg = beautiful.bg_focus
widgets.count:buttons(
awful.util.table.join(
awful.button({ }, 1, function (c) showmail(name) end)))
return widgets
end
function focus_raise(direction)
awful.client.focus.bydirection(direction)
if client.focus then client.focus:raise() end
end
function ror_browser()
ext.run_or_raise("conkeror", { class = "Conkeror" })
end
function ror_editor()
ext.run_or_raise("emacsclient -c -a emacs", { class = "Emacs" })
end
function ror_term()
ext.run_or_raise("urxvt", { class = "URxvt" })
end
function run_browser()
awful.util.spawn("conkeror")
end
function run_editor()
awful.util.spawn("emacsclient -c -a emacs")
end
function run_term()
awful.util.spawn("urxvt")
end
|