summaryrefslogtreecommitdiffstats
path: root/.config/awesome/rc.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/awesome/rc.lua')
-rw-r--r--.config/awesome/rc.lua145
1 files changed, 14 insertions, 131 deletions
diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua
index 5e07a09..b83de13 100644
--- a/.config/awesome/rc.lua
+++ b/.config/awesome/rc.lua
@@ -4,12 +4,9 @@ require("awful.rules")
require("beautiful")
require("bowl")
require("keychain")
-require("lfs")
require("naughty")
-
-oni = { } -- Container for custom functions.
-
-oni.maildirfmt = "/home/slash/documents/mail/%s/inbox/new/"
+require("ext")
+require("oni")
--- Error handling
-- Check if awesome encountered an error during startup and fell back to
@@ -35,111 +32,6 @@ do
end)
end
---- Functions
-function oni.focus_raise(direction)
- awful.client.focus.bydirection(direction)
- if client.focus then client.focus:raise() end
-end
-
-function oni.mailcount(account)
- local i = 0
- local dir = string.format(oni.maildirfmt, account)
-
- for file in lfs.dir(dir) do
- if file ~= "." and file ~= ".." then
- i = i + 1
- end
- end
-
- return i
-end
-
-function oni.mailcount_text()
- return string.format(" ryu: %d aet: %d gmail: %d 9f: %d --",
- oni.mailcount("ryuslash.org"),
- oni.mailcount("aethon"),
- oni.mailcount("gmail"),
- oni.mailcount("ninthfloor"))
-end
-
-function oni.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 ", oni.mailcount(account))
- widgets.count.bg = beautiful.bg_focus
- widgets.count:buttons(
- awful.util.table.join(
- awful.button({ }, 1,
- function (c)
- awful.util.spawn("emacsclient -e '(oni:view-mail \"" .. name .. "\")'")
- end)))
-
- return widgets
-end
-
--- Returns true if all pairs in table1 are present in table2
-function oni.match(table1, table2)
- for k, v in pairs(table1) do
- if table[k] ~= v and not table2[k]:find(v) then
- return false
- end
- end
-
- return true
-end
-
---- Spawns cmd if no client can be found matching properties
--- If such a client can be found, pop to first tag where it is
--- visible, and give it focus
-function oni.run_or_raise(cmd, properties)
- local clients = client.get()
- local focused = awful.client.next(0)
- local findex = 0
- local matched_clients = { }
- local n = 0
-
- for i, c in pairs(clients) do
- -- make an array of matched clients
- if oni.match(properties, c) then
- n = n + 1
- matched_clients[n] = c
-
- if n == focused then
- findex = n
- end
- end
- end
-
- if n > 0 then
- local c = matched_clients[1]
-
- -- if the focused window matched switch focus to next in list
- if 0 < findex and findex < n then
- c = matched_clients[findex + 1]
- end
-
- local ctags = c:tags()
-
- if table.getn(ctags) == 0 then
- -- ctags is empty, show client on current tag
- local curtag = awful.tag.selected()
- awful.client.movetotag(curtag, c)
- else
- -- Otherwise, pop to first tag client is visible on
- awful.tag.viewonly(ctags[1])
- end
-
- -- And then focus the client
- client.focus = c
- c:raise()
- awful.screen.focus(c.screen)
- return
- end
- awful.util.spawn(cmd)
-end
-
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
beautiful.init("/home/slash/.config/awesome/themes/custom/theme.lua")
@@ -347,29 +239,20 @@ globalkeys = awful.util.table.join(
sub({ }, "f", function () oni.focus_raise("right") end),
sub({ }, "b", function () oni.focus_raise("left") end),
sub({ }, "n", function () oni.focus_raise("down") end),
- sub({ }, "p", function () oni.focus_raise("up") end),
- sub({ }, "e",
- function () oni.run_or_raise("emacsclient -c -a emacs",
- { class = "Emacs" }) end),
- sub({ "Shift", }, "e",
- function () awful.util.spawn("emacsclient -c -a emacs") end),
- sub({ }, "c",
- function () oni.run_or_raise("urxvt",
- { class = "URxvt" }) end),
- sub({ "Shift", }, "c",
- function () awful.util.spawn("urxvt") end),
- sub({ }, "w",
- function () oni.run_or_raise("conkeror",
- { class = "Conkeror" }) end),
- sub({ "Shift", }, "w",
- function () awful.util.spawn("conkeror") end) }),
+ sub({ }, "p", function () oni.focus_raise("up") end) }),
awful.key({ "Control", "Mod1" }, "l",
function () awful.util.spawn("i3lock -c 000000") end),
- awful.key({ modkey, }, "Left", awful.tag.viewprev ),
- awful.key({ modkey, }, "Right", awful.tag.viewnext ),
- awful.key({ modkey, }, "Escape", awful.tag.history.restore),
-
- awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
+ awful.key({ "Mod4", }, "c", oni.ror_term),
+ awful.key({ "Mod4", "Shift" }, "c", oni.run_term),
+ awful.key({ "Mod4", }, "e", oni.ror_editor),
+ awful.key({ "Mod4", "Shift" }, "e", oni.run_editor),
+ awful.key({ "Mod4", }, "w", oni.ror_browser),
+ awful.key({ "Mod4", "Shift" }, "w", oni.run_browser),
+ awful.key({ modkey, }, "Left", awful.tag.viewprev ),
+ awful.key({ modkey, }, "Right", awful.tag.viewnext ),
+ awful.key({ modkey, }, "Escape", awful.tag.history.restore),
+
+ -- awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),