diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-07-29 17:59:32 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-07-29 17:59:32 +0200 |
commit | 98e26ee0436822b00d4a6e707d86cf33d24bc00f (patch) | |
tree | a2a77a85453835d6235b9a4ee8a4044433c37151 /org.lua | |
download | vicious-legacy-98e26ee0436822b00d4a6e707d86cf33d24bc00f.tar.xz |
Import of vicious source tree.v1.0.0
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
Diffstat (limited to 'org.lua')
-rw-r--r-- | org.lua | 70 |
1 files changed, 70 insertions, 0 deletions
@@ -0,0 +1,70 @@ +---------------------------------------------------------- +-- Licensed under the GNU General Public License version 2 +-- * Copyright (C) 2009 Adrian C. <anrxc_sysphere_org> +-- * Derived from org-awesome, copyright of Damien Leone +---------------------------------------------------------- + +-- {{{ Grab environment +local io = { open = io.open } +local string = { find = string.find } +local os = { + time = os.time, + date = os.date +} +-- }}} + + +-- Org: provides agenda statistics for Emacs org-mode +module("vicious.org") + + +-- {{{ OrgMode widget type +function worker(format, files) + -- Compute delays + local today = os.time{ year=os.date("%Y"), month=os.date("%m"), day=os.date("%d") } + local soon = today + 24 * 3600 * 3 -- 3 days ahead is close + local future = today + 24 * 3600 * 7 -- 7 days ahead is maximum + + -- Initialise count table + local count = { + past = 0, + today = 0, + soon = 0, + future = 0 + } + + -- Get data from agenda files + for i=1, #files do + local f = io.open(files[i]) + + -- Parse the agenda + for line in f:lines() do + local scheduled = string.find(line, "SCHEDULED:") + local closed = string.find(line, "CLOSED:") + local deadline = string.find(line, "DEADLINE:") + + if (scheduled and not closed) or (deadline and not closed) then + local b, e, y, m, d = string.find(line, "(%d%d%d%d)-(%d%d)-(%d%d)") + + -- Enumerate agenda items + if b then + local t = os.time{ year = y, month = m, day = d } + + if t < today then + count.past = count.past + 1 + elseif t == today then + count.today = count.today + 1 + elseif t <= soon then + count.soon = count.soon + 1 + elseif t <= future then + count.future = count.future + 1 + end + end + end + end + f:close() + end + + return {count.past, count.today, count.soon, count.future} +end +-- }}} |