General cleanup
This commit is contained in:
parent
4f3599db00
commit
2a5126f4f0
1
bat.lua
1
bat.lua
|
@ -22,7 +22,6 @@ module("vicious.bat")
|
||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
local function worker(format, batid)
|
local function worker(format, batid)
|
||||||
-- Initialise tables
|
|
||||||
local battery_state = {
|
local battery_state = {
|
||||||
["full"] = "↯",
|
["full"] = "↯",
|
||||||
["unknown"] = "⌁",
|
["unknown"] = "⌁",
|
||||||
|
|
|
@ -16,7 +16,6 @@ module("vicious.batat")
|
||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
-- Initialise tables
|
|
||||||
local battery_info = {}
|
local battery_info = {}
|
||||||
local battery_state = {
|
local battery_state = {
|
||||||
["full"] = "↯",
|
["full"] = "↯",
|
||||||
|
@ -29,7 +28,6 @@ local function worker(format)
|
||||||
-- Get data from acpitool
|
-- Get data from acpitool
|
||||||
local f = io.popen("acpitool -b")
|
local f = io.popen("acpitool -b")
|
||||||
|
|
||||||
-- Format data
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
-- Check if the battery is present
|
-- Check if the battery is present
|
||||||
if line:match("^[%s]+Battery.*") then
|
if line:match("^[%s]+Battery.*") then
|
||||||
|
|
2
cpu.lua
2
cpu.lua
|
@ -27,7 +27,6 @@ local function worker(format)
|
||||||
local f = io.open("/proc/stat")
|
local f = io.open("/proc/stat")
|
||||||
local cpu_lines = {}
|
local cpu_lines = {}
|
||||||
|
|
||||||
-- Format data
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
if line:find("^cpu") then
|
if line:find("^cpu") then
|
||||||
if #cpu_lines < 1 then cpuid = 1
|
if #cpu_lines < 1 then cpuid = 1
|
||||||
|
@ -52,7 +51,6 @@ local function worker(format)
|
||||||
table.insert(cpu_usage, 0)
|
table.insert(cpu_usage, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup tables
|
|
||||||
local total_new = {}
|
local total_new = {}
|
||||||
local active_new = {}
|
local active_new = {}
|
||||||
local diff_total = {}
|
local diff_total = {}
|
||||||
|
|
|
@ -19,7 +19,6 @@ module("vicious.cpufreq")
|
||||||
|
|
||||||
-- {{{ CPU frequency widget type
|
-- {{{ CPU frequency widget type
|
||||||
local function worker(format, cpuid)
|
local function worker(format, cpuid)
|
||||||
-- Initialise tables
|
|
||||||
--local governor_state = {
|
--local governor_state = {
|
||||||
-- ["ondemand"] = "↯",
|
-- ["ondemand"] = "↯",
|
||||||
-- ["powersave"] = "⌁",
|
-- ["powersave"] = "⌁",
|
||||||
|
|
|
@ -16,25 +16,21 @@ module("vicious.cpuinf")
|
||||||
|
|
||||||
-- {{{ CPU Information widget type
|
-- {{{ CPU Information widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
-- Initialise variables
|
|
||||||
cpu_id = nil
|
cpu_id = nil
|
||||||
|
|
||||||
-- Get cpuinfo
|
-- Get cpuinfo
|
||||||
local f = io.open("/proc/cpuinfo")
|
local f = io.open("/proc/cpuinfo")
|
||||||
local cpu_info = {}
|
local cpu_info = {}
|
||||||
|
|
||||||
-- Get data
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
if line:match("^processor.*") then
|
if line:match("^processor.*") then
|
||||||
cpu_id = line:match("([%d]+)")
|
cpu_id = line:match("([%d]+)")
|
||||||
elseif line:match("^cpu MHz.*") then
|
elseif line:match("^cpu MHz.*") then
|
||||||
local cpu_speed = line:match("([%d]+)%.")
|
local cpu_speed = line:match("([%d]+)%.")
|
||||||
-- Store values
|
|
||||||
cpu_info["{"..cpu_id.." mhz}"] = cpu_speed
|
cpu_info["{"..cpu_id.." mhz}"] = cpu_speed
|
||||||
cpu_info["{"..cpu_id.." ghz}"] = tonumber(cpu_speed) / 1000
|
cpu_info["{"..cpu_id.." ghz}"] = tonumber(cpu_speed) / 1000
|
||||||
elseif line:match("^cache size.*") then
|
elseif line:match("^cache size.*") then
|
||||||
local cpu_cache = line:match("([%d]+)[%s]KB")
|
local cpu_cache = line:match("([%d]+)[%s]KB")
|
||||||
-- Store values
|
|
||||||
cpu_info["{"..cpu_id.." kb}"] = cpu_cache
|
cpu_info["{"..cpu_id.." kb}"] = cpu_cache
|
||||||
cpu_info["{"..cpu_id.." mb}"] = tonumber(cpu_cache) / 1024
|
cpu_info["{"..cpu_id.." mb}"] = tonumber(cpu_cache) / 1024
|
||||||
end
|
end
|
||||||
|
|
1
date.lua
1
date.lua
|
@ -15,7 +15,6 @@ module("vicious.date")
|
||||||
|
|
||||||
-- {{{ Date widget type
|
-- {{{ Date widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
-- Get format
|
|
||||||
if format == nil then
|
if format == nil then
|
||||||
return os.date()
|
return os.date()
|
||||||
else
|
else
|
||||||
|
|
2
dio.lua
2
dio.lua
|
@ -27,7 +27,6 @@ local function worker(format, disk)
|
||||||
local f = io.open("/proc/diskstats")
|
local f = io.open("/proc/diskstats")
|
||||||
local disk_lines = {}
|
local disk_lines = {}
|
||||||
|
|
||||||
-- Format data
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
if line:match("("..disk..")%s") then
|
if line:match("("..disk..")%s") then
|
||||||
-- Todo: find a way to do this
|
-- Todo: find a way to do this
|
||||||
|
@ -52,7 +51,6 @@ local function worker(format, disk)
|
||||||
table.insert(disk_total, 0)
|
table.insert(disk_total, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup tables
|
|
||||||
local diff_total = {}
|
local diff_total = {}
|
||||||
|
|
||||||
for i, v in ipairs(disk_lines) do
|
for i, v in ipairs(disk_lines) do
|
||||||
|
|
3
fs.lua
3
fs.lua
|
@ -20,11 +20,10 @@ local function worker(format)
|
||||||
local f = io.popen("LANG=C df -hP")
|
local f = io.popen("LANG=C df -hP")
|
||||||
local fs_info = {}
|
local fs_info = {}
|
||||||
|
|
||||||
-- Format data
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
if not line:match("^Filesystem.*") then
|
if not line:match("^Filesystem.*") then
|
||||||
-- Format helper can't deal with matrices, so don't setup a
|
-- Format helper can't deal with matrices, so don't setup a
|
||||||
-- table for each mount point with gmatch
|
-- table for each mount point, with gmatch
|
||||||
local size, used, avail, usep, mount =
|
local size, used, avail, usep, mount =
|
||||||
-- Instead match all at once, including network file systems
|
-- Instead match all at once, including network file systems
|
||||||
line:match("^[%w%p]+[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d]+)%%[%s]+([%w%p]+)$")
|
line:match("^[%w%p]+[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d]+)%%[%s]+([%w%p]+)$")
|
||||||
|
|
|
@ -16,7 +16,6 @@ module("vicious.gmail")
|
||||||
|
|
||||||
-- {{{ Gmail widget type
|
-- {{{ Gmail widget type
|
||||||
local function worker(format, login)
|
local function worker(format, login)
|
||||||
-- Initialise tables
|
|
||||||
local mail = {
|
local mail = {
|
||||||
["{count}"] = "0",
|
["{count}"] = "0",
|
||||||
["{subject}"] = "N/A"
|
["{subject}"] = "N/A"
|
||||||
|
|
|
@ -22,7 +22,6 @@ local function worker(format, port)
|
||||||
local f = io.popen("curl --connect-timeout 1 -fsm 3 telnet://127.0.0.1:" .. port)
|
local f = io.popen("curl --connect-timeout 1 -fsm 3 telnet://127.0.0.1:" .. port)
|
||||||
local hdd_temp = {}
|
local hdd_temp = {}
|
||||||
|
|
||||||
-- Get temperature data
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
local disk, temp = line:match("|([%/%a]+)|.*|([%d]+)|[CF]+|")
|
local disk, temp = line:match("|([%/%a]+)|.*|([%d]+)|[CF]+|")
|
||||||
|
|
||||||
|
|
39
init.lua
39
init.lua
|
@ -1,16 +1,13 @@
|
||||||
----------------------------------------------------------------
|
--------------------------------------------------------------
|
||||||
-- Vicious widgets for the awesome window manager
|
-- Vicious widgets for the awesome window manager
|
||||||
--
|
--------------------------------------------------------------
|
||||||
-- Licensed under the GNU General Public License version 2
|
-- Licensed under the GNU General Public License version 2
|
||||||
-- * Copyright (C) 2009 Adrian C. <anrxc_sysphere_org>
|
-- * Copyright (C) 2009 Adrian C. <anrxc_sysphere_org>
|
||||||
--
|
--------------------------------------------------------------
|
||||||
-- To view a human-readable summary of the license, visit:
|
|
||||||
-- * http://creativecommons.org/licenses/GPL/2.0/
|
|
||||||
----------------------------------------------------------------
|
|
||||||
-- Derived from Wicked, by Lucas de Vries <lucas_glacicle_com>
|
-- Derived from Wicked, by Lucas de Vries <lucas_glacicle_com>
|
||||||
-- * http://git.glacicle.com/cgit.cgi/wicked
|
-- * http://git.glacicle.com/cgit.cgi/wicked
|
||||||
-- * Wicked is licensed under the WTFPL v2
|
-- * Wicked is licensed under the WTFPL v2
|
||||||
----------------------------------------------------------------
|
--------------------------------------------------------------
|
||||||
|
|
||||||
-- {{{ Grab environment
|
-- {{{ Grab environment
|
||||||
require("awful")
|
require("awful")
|
||||||
|
@ -63,7 +60,7 @@ require("vicious.date")
|
||||||
module("vicious")
|
module("vicious")
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Initialise variables
|
-- {{{ Initialise tables
|
||||||
local timers = {}
|
local timers = {}
|
||||||
local registered = {}
|
local registered = {}
|
||||||
local widget_cache = {}
|
local widget_cache = {}
|
||||||
|
@ -88,7 +85,7 @@ end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Main functions
|
-- {{{ Main functions
|
||||||
-- {{{ Register widget
|
-- {{{ Register a widget
|
||||||
function register(widget, wtype, format, timer, warg)
|
function register(widget, wtype, format, timer, warg)
|
||||||
local reg = {}
|
local reg = {}
|
||||||
local widget = widget
|
local widget = widget
|
||||||
|
@ -110,10 +107,10 @@ function register(widget, wtype, format, timer, warg)
|
||||||
reg.timer = 1
|
reg.timer = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register reg object
|
-- Register a reg object
|
||||||
regregister(reg)
|
regregister(reg)
|
||||||
|
|
||||||
-- Return reg object for reuse
|
-- Return a reg object for reuse
|
||||||
return reg
|
return reg
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
@ -121,12 +118,11 @@ end
|
||||||
-- {{{ Register from reg object
|
-- {{{ Register from reg object
|
||||||
function regregister(reg)
|
function regregister(reg)
|
||||||
if not reg.running then
|
if not reg.running then
|
||||||
-- Put widget in table
|
|
||||||
if registered[reg.widget] == nil then
|
if registered[reg.widget] == nil then
|
||||||
registered[reg.widget] = {}
|
registered[reg.widget] = {}
|
||||||
table.insert(registered[reg.widget], reg)
|
table.insert(registered[reg.widget], reg)
|
||||||
else
|
else
|
||||||
already = false
|
local already = false
|
||||||
|
|
||||||
for w, i in pairs(registered) do
|
for w, i in pairs(registered) do
|
||||||
if w == reg.widget then
|
if w == reg.widget then
|
||||||
|
@ -148,7 +144,7 @@ function regregister(reg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Start timer
|
-- Start the timer
|
||||||
if reg.timer > 0 then
|
if reg.timer > 0 then
|
||||||
timers[reg.update] = {
|
timers[reg.update] = {
|
||||||
timer = capi.timer({ timeout = reg.timer })
|
timer = capi.timer({ timeout = reg.timer })
|
||||||
|
@ -159,14 +155,12 @@ function regregister(reg)
|
||||||
|
|
||||||
-- Initial update
|
-- Initial update
|
||||||
reg.update()
|
reg.update()
|
||||||
|
|
||||||
-- Set running
|
|
||||||
reg.running = true
|
reg.running = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Unregister widget
|
-- {{{ Unregister a widget
|
||||||
function unregister(widget, keep, reg)
|
function unregister(widget, keep, reg)
|
||||||
if reg == nil then
|
if reg == nil then
|
||||||
for w, i in pairs(registered) do
|
for w, i in pairs(registered) do
|
||||||
|
@ -192,7 +186,7 @@ function unregister(widget, keep, reg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Stop timer
|
-- Stop the timer
|
||||||
if timers[reg.update].timer.started then
|
if timers[reg.update].timer.started then
|
||||||
timers[reg.update].timer:stop()
|
timers[reg.update].timer:stop()
|
||||||
end
|
end
|
||||||
|
@ -202,7 +196,7 @@ function unregister(widget, keep, reg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Suspend vicious, halt all widget updates
|
-- {{{ Suspend vicious
|
||||||
function suspend()
|
function suspend()
|
||||||
for w, i in pairs(registered) do
|
for w, i in pairs(registered) do
|
||||||
for _, v in pairs(i) do
|
for _, v in pairs(i) do
|
||||||
|
@ -212,7 +206,7 @@ function suspend()
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Activate vicious, restart all widget updates
|
-- {{{ Activate vicious
|
||||||
function activate(widget)
|
function activate(widget)
|
||||||
for w, i in pairs(registered) do
|
for w, i in pairs(registered) do
|
||||||
if widget == nil or w == widget then
|
if widget == nil or w == widget then
|
||||||
|
@ -224,7 +218,7 @@ function activate(widget)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Update widget
|
-- {{{ Update a widget
|
||||||
function update(widget, reg, disablecache)
|
function update(widget, reg, disablecache)
|
||||||
-- Check if there are any equal widgets
|
-- Check if there are any equal widgets
|
||||||
if reg == nil then
|
if reg == nil then
|
||||||
|
@ -242,8 +236,7 @@ function update(widget, reg, disablecache)
|
||||||
local t = os.time()
|
local t = os.time()
|
||||||
local data = {}
|
local data = {}
|
||||||
|
|
||||||
-- Check if we have output chached for this widget newer than last
|
-- Do we have output chached for a widget newer than last update
|
||||||
-- widget update
|
|
||||||
if widget_cache[reg.type] ~= nil then
|
if widget_cache[reg.type] ~= nil then
|
||||||
local c = widget_cache[reg.type]
|
local c = widget_cache[reg.type]
|
||||||
|
|
||||||
|
|
1
load.lua
1
load.lua
|
@ -20,7 +20,6 @@ local function worker(format)
|
||||||
local line = f:read("*line")
|
local line = f:read("*line")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Get load data
|
|
||||||
local avg1, avg5, avg15 =
|
local avg1, avg5, avg15 =
|
||||||
line:match("([%d]*%.[%d]*)%s([%d]*%.[%d]*)%s([%d]*%.[%d]*)")
|
line:match("([%d]*%.[%d]*)%s([%d]*%.[%d]*)%s([%d]*%.[%d]*)")
|
||||||
|
|
||||||
|
|
3
mbox.lua
3
mbox.lua
|
@ -21,12 +21,9 @@ local function worker(format, mbox)
|
||||||
-- mbox could be huge, get a 15kb chunk from EOF
|
-- mbox could be huge, get a 15kb chunk from EOF
|
||||||
-- * attachments could be much bigger than this
|
-- * attachments could be much bigger than this
|
||||||
f:seek("end", -15360)
|
f:seek("end", -15360)
|
||||||
|
|
||||||
-- Get data
|
|
||||||
local text = f:read("*all")
|
local text = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Find subject lines
|
|
||||||
for match in string.gfind(text, "Subject: ([^\n]*)") do
|
for match in string.gfind(text, "Subject: ([^\n]*)") do
|
||||||
subject = match
|
subject = match
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,17 +21,11 @@ local function worker(format, mbox)
|
||||||
local total = 0
|
local total = 0
|
||||||
|
|
||||||
-- Open the mbox
|
-- Open the mbox
|
||||||
--
|
|
||||||
-- If we had LuaFileSystem we could check the mtime and size of
|
|
||||||
-- the file and if they didn't change since the last read we could
|
|
||||||
-- return the old, cached, count. However, we didn't rely on extra
|
|
||||||
-- libraries to this point so we won't start now.
|
|
||||||
local f = io.open(mbox)
|
local f = io.open(mbox)
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
-- Read the mbox line by line, if we are going to read some
|
-- Read the mbox line by line, if we are going to read some
|
||||||
-- *HUGE* folders then switch to reading chunks. It's why we are
|
-- *HUGE* folders then switch to reading chunks
|
||||||
-- not reading the whole file at once in the first place.
|
|
||||||
local lines = f:read("*line")
|
local lines = f:read("*line")
|
||||||
if not lines then break end
|
if not lines then break end
|
||||||
|
|
||||||
|
|
6
mdir.lua
6
mdir.lua
|
@ -16,12 +16,6 @@ module("vicious.mdir")
|
||||||
|
|
||||||
-- {{{ Maildir widget type
|
-- {{{ Maildir widget type
|
||||||
local function worker(format, mdir)
|
local function worker(format, mdir)
|
||||||
-- Like with the mbox count widget, we would benefit from the
|
|
||||||
-- LuaFileSystem library. However, we didn't rely on extra
|
|
||||||
-- libraries to this point so we won't start now. Widgets like
|
|
||||||
-- this one are not agressive like CPU or NET, so we can keep it
|
|
||||||
-- simple, find is OK with me if we execute every >60s
|
|
||||||
--
|
|
||||||
-- Initialise counters
|
-- Initialise counters
|
||||||
local newcount = 0
|
local newcount = 0
|
||||||
local curcount = 0
|
local curcount = 0
|
||||||
|
|
1
mem.lua
1
mem.lua
|
@ -20,7 +20,6 @@ local function worker(format)
|
||||||
-- Get meminfo
|
-- Get meminfo
|
||||||
local f = io.open("/proc/meminfo")
|
local f = io.open("/proc/meminfo")
|
||||||
|
|
||||||
-- Get data
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
if line:match("^MemTotal.*") then
|
if line:match("^MemTotal.*") then
|
||||||
mem_total = math.floor(tonumber(line:match("([%d]+)")) / 1024)
|
mem_total = math.floor(tonumber(line:match("([%d]+)")) / 1024)
|
||||||
|
|
4
mpd.lua
4
mpd.lua
|
@ -16,10 +16,6 @@ module("vicious.mpd")
|
||||||
|
|
||||||
-- {{{ MPD widget type
|
-- {{{ MPD widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
-- This one is as simple as they come. Using sockets or expanding
|
|
||||||
-- it is a lost cause since there are already a few MPD Lua libs
|
|
||||||
-- written for awesome. Use them.
|
|
||||||
--
|
|
||||||
-- Get data from mpc
|
-- Get data from mpc
|
||||||
local f = io.popen("mpc")
|
local f = io.popen("mpc")
|
||||||
local np = f:read("*line")
|
local np = f:read("*line")
|
||||||
|
|
3
net.lua
3
net.lua
|
@ -25,7 +25,6 @@ local function worker(format)
|
||||||
local f = io.open("/proc/net/dev")
|
local f = io.open("/proc/net/dev")
|
||||||
local args = {}
|
local args = {}
|
||||||
|
|
||||||
-- Format data
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
-- Match wmaster0 as well as rt0 (multiple leading spaces)
|
-- Match wmaster0 as well as rt0 (multiple leading spaces)
|
||||||
if line:match("^[%s]?[%s]?[%s]?[%s]?[%w]+:") then
|
if line:match("^[%s]?[%s]?[%s]?[%s]?[%w]+:") then
|
||||||
|
@ -48,7 +47,7 @@ local function worker(format)
|
||||||
args["{"..name.." tx_gb}"] = math.floor(send/1024/1024/1024*10)/10
|
args["{"..name.." tx_gb}"] = math.floor(send/1024/1024/1024*10)/10
|
||||||
|
|
||||||
if nets[name] == nil then
|
if nets[name] == nil then
|
||||||
-- Default values on our first run
|
-- Default values on the first run
|
||||||
nets[name] = {}
|
nets[name] = {}
|
||||||
args["{"..name.." down}"] = "n/a"
|
args["{"..name.." down}"] = "n/a"
|
||||||
args["{"..name.." up}"] = "n/a"
|
args["{"..name.." up}"] = "n/a"
|
||||||
|
|
4
org.lua
4
org.lua
|
@ -26,7 +26,7 @@ local function worker(format, files)
|
||||||
local soon = today + 24 * 3600 * 3 -- 3 days ahead is close
|
local soon = today + 24 * 3600 * 3 -- 3 days ahead is close
|
||||||
local future = today + 24 * 3600 * 7 -- 7 days ahead is maximum
|
local future = today + 24 * 3600 * 7 -- 7 days ahead is maximum
|
||||||
|
|
||||||
-- Initialise count table
|
-- Initialise counters
|
||||||
local count = {
|
local count = {
|
||||||
past = 0,
|
past = 0,
|
||||||
today = 0,
|
today = 0,
|
||||||
|
@ -38,7 +38,6 @@ local function worker(format, files)
|
||||||
for i=1, #files do
|
for i=1, #files do
|
||||||
local f = io.open(files[i])
|
local f = io.open(files[i])
|
||||||
|
|
||||||
-- Parse the agenda
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
local scheduled = string.find(line, "SCHEDULED:")
|
local scheduled = string.find(line, "SCHEDULED:")
|
||||||
local closed = string.find(line, "CLOSED:")
|
local closed = string.find(line, "CLOSED:")
|
||||||
|
@ -47,7 +46,6 @@ local function worker(format, files)
|
||||||
if (scheduled and not closed) or (deadline and not closed) then
|
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)")
|
local b, e, y, m, d = string.find(line, "(%d%d%d%d)-(%d%d)-(%d%d)")
|
||||||
|
|
||||||
-- Enumerate agenda items
|
|
||||||
if b then
|
if b then
|
||||||
local t = os.time{ year = y, month = m, day = d }
|
local t = os.time{ year = y, month = m, day = d }
|
||||||
|
|
||||||
|
|
21
pacman.lua
21
pacman.lua
|
@ -16,27 +16,22 @@ module("vicious.pacman")
|
||||||
|
|
||||||
-- {{{ Pacman widget type
|
-- {{{ Pacman widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
|
-- Initialise counters
|
||||||
|
local updates = 0
|
||||||
|
|
||||||
-- Check if updates are available
|
-- Check if updates are available
|
||||||
local f = io.popen("pacman -Qu")
|
local f = io.popen("pacman -Qu")
|
||||||
|
|
||||||
-- Initialise updates
|
|
||||||
local updates = 0
|
|
||||||
|
|
||||||
-- Get data
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
-- Pacman 3.3 returns one package on a line, without any extra
|
-- Pacman 3.2 provides the number of available updates
|
||||||
-- information
|
|
||||||
updates = updates + 1
|
|
||||||
|
|
||||||
-- Pacman 3.2 returns 'Targets:' followed by a number of
|
|
||||||
-- available updates and a list of packages all on one
|
|
||||||
-- line. Since the number is provided we don't have to count
|
|
||||||
-- them
|
|
||||||
--updates = line:match("^Targets[%s]%(([%d]+)%)") or 0
|
--updates = line:match("^Targets[%s]%(([%d]+)%)") or 0
|
||||||
-- If the count changed then break out of the loop
|
---- If the count changed then break out of the loop
|
||||||
--if tonumber(updates) > 0 then
|
--if tonumber(updates) > 0 then
|
||||||
-- break
|
-- break
|
||||||
--end
|
--end
|
||||||
|
|
||||||
|
-- Pacman 3.3 returns one line per package
|
||||||
|
updates = updates + 1
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ local function worker(format, thermal_zone)
|
||||||
local line = f:read("*line")
|
local line = f:read("*line")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Get temperature data
|
|
||||||
local temperature = line:match("[%d]?[%d]?[%d]")
|
local temperature = line:match("[%d]?[%d]?[%d]")
|
||||||
|
|
||||||
return {temperature}
|
return {temperature}
|
||||||
|
|
|
@ -22,9 +22,7 @@ local function worker(format)
|
||||||
local line = f:read("*line")
|
local line = f:read("*line")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Format data
|
|
||||||
local total_uptime = math.floor(tonumber(line:match("[%d%.]+")))
|
local total_uptime = math.floor(tonumber(line:match("[%d%.]+")))
|
||||||
|
|
||||||
local uptime_days = math.floor(total_uptime / (3600 * 24))
|
local uptime_days = math.floor(total_uptime / (3600 * 24))
|
||||||
local uptime_hours = math.floor((total_uptime % (3600 * 24)) / 3600)
|
local uptime_hours = math.floor((total_uptime % (3600 * 24)) / 3600)
|
||||||
local uptime_minutes = math.floor(((total_uptime % (3600 * 24)) % 3600) / 60)
|
local uptime_minutes = math.floor(((total_uptime % (3600 * 24)) % 3600) / 60)
|
||||||
|
|
|
@ -21,13 +21,10 @@ local function worker(format, channel)
|
||||||
local mixer = f:read("*all")
|
local mixer = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Get volume level
|
|
||||||
local volume_level = string.match(mixer, "([%d]?[%d]?[%d])%%")
|
local volume_level = string.match(mixer, "([%d]?[%d]?[%d])%%")
|
||||||
|
|
||||||
-- Don't break progressbars
|
-- Don't break progressbars
|
||||||
if volume_level == nil then
|
if volume_level == nil then return {0} end
|
||||||
return {0}
|
|
||||||
end
|
|
||||||
|
|
||||||
return {volume_level}
|
return {volume_level}
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ module("vicious.weather")
|
||||||
-- {{{ Weather widget type
|
-- {{{ Weather widget type
|
||||||
local function worker(format, station)
|
local function worker(format, station)
|
||||||
-- US National Oceanic and Atmospheric Administration
|
-- US National Oceanic and Atmospheric Administration
|
||||||
-- * Station (ICAO) codes: http://www.rap.ucar.edu/weather/surface/stations.txt
|
-- * ICAO codes: http://www.rap.ucar.edu/weather/surface/stations.txt
|
||||||
local noaa = "http://weather.noaa.gov/pub/data/observations/metar/decoded/"
|
local noaa = "http://weather.noaa.gov/pub/data/observations/metar/decoded/"
|
||||||
|
|
||||||
-- Get info from a weather station
|
-- Get info from a weather station
|
||||||
|
@ -26,11 +26,8 @@ local function worker(format, station)
|
||||||
local ws = f:read("*all")
|
local ws = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Setup tables
|
-- Default values
|
||||||
local weather = {
|
local weather = {
|
||||||
-- Some of the weather symbols would look nice if prepended to
|
|
||||||
-- the final output, but it is up to the user to do that
|
|
||||||
-- * http://www.alanwood.net/unicode/miscellaneous_symbols.html
|
|
||||||
["{city}"] = "N/A",
|
["{city}"] = "N/A",
|
||||||
["{wind}"] = "N/A",
|
["{wind}"] = "N/A",
|
||||||
["{windmph}"] = "N/A",
|
["{windmph}"] = "N/A",
|
||||||
|
|
5
wifi.lua
5
wifi.lua
|
@ -19,13 +19,12 @@ module("vicious.wifi")
|
||||||
|
|
||||||
-- {{{ Wireless widget type
|
-- {{{ Wireless widget type
|
||||||
local function worker(format, iface)
|
local function worker(format, iface)
|
||||||
-- Get data from iwconfig, on distributions where it is executable
|
-- Get data from iwconfig (where available)
|
||||||
-- by users, and /sbin or /usr/sbin is in their path
|
|
||||||
local f = io.popen("iwconfig " .. iface)
|
local f = io.popen("iwconfig " .. iface)
|
||||||
local iw = f:read("*all")
|
local iw = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Setup tables
|
-- Default values
|
||||||
local winfo = {
|
local winfo = {
|
||||||
["{ssid}"] = "N/A",
|
["{ssid}"] = "N/A",
|
||||||
["{mode}"] = "N/A",
|
["{mode}"] = "N/A",
|
||||||
|
|
Loading…
Reference in New Issue