From ddff03f5ecf8a06c0e57feef2f03103fa0c1b467 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 13 Sep 2012 10:32:33 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 099d3c5..b602eb7 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -1,15 +1,15 @@ --- Standard awesome library require("awful") require("awful.autofocus") require("awful.rules") --- Theme handling library require("beautiful") --- Notification library -require("naughty") require("bowl") require("keychain") +require("lfs") +require("naughty") + +oni = { } -- Container for custom functions. -oni = { } -- Container for custom functions. +oni.maildirfmt = "/home/slash/documents/mail/%s/inbox/new/" -- {{{ Error handling -- Check if awesome encountered an error during startup and fell back to @@ -41,8 +41,21 @@ function oni.focus_raise(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 + -- Returns true if all pairs in table1 are present in table2 -function match(table1, 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 @@ -64,7 +77,7 @@ function oni.run_or_raise(cmd, properties) for i, c in pairs(clients) do -- make an array of matched clients - if match(properties, c) then + if oni.match(properties, c) then n = n + 1 matched_clients[n] = c @@ -108,6 +121,11 @@ beautiful.init("/usr/share/awesome/themes/default/theme.lua") bowl.init({ use_timers = true, timeout = 1 }) bowl.default_setup() +keychain.init({ escapes = { + keychain.keystroke ({ }, "Escape"), + keychain.keystroke ({ "Control", }, "g") +} }) + -- This is used later as the default terminal and editor to run. terminal = "urxvt" editor = os.getenv("EDITOR") or "nano" -- cgit v1.2.3-54-g00ecf