This commit is contained in:
Joerg T. (Mic92) 2010-05-09 10:21:36 +02:00
commit c5772894fa
16 changed files with 108 additions and 43 deletions

7
README
View File

@ -172,6 +172,12 @@ vicious.widgets.dio
{read_s}, {read_kb}, {read_mb}, {write_s}, {write_kb}, {write_mb}
and {sched}
vicious.widgets.raid
- provides state information for a requested RAID array
- takes the RAID array ID as an argument
- returns 1st value as the number of assigned, and 2nd as active,
devices in the array
vicious.widgets.hddtemp
- provides hard drive temperatures using the hddtemp daemon
- takes the hddtemp listening port as an argument, or defaults to
@ -501,3 +507,4 @@ Vicious contributors:
- Henning Glawe <glaweh debian.org>
- Rémy C. <shikamaru mandriva.org>
- Hiltjo Posthuma <hiltjo codemadness.org>
- Hagen Schink <troja84 googlemail.com>

View File

@ -15,7 +15,7 @@ local math = {
-- }}}
-- Batsys: provides state, charge, and remaining time for a requested battery
-- Bat: provides state, charge, and remaining time for a requested battery
module("vicious.widgets.bat")

View File

@ -21,7 +21,7 @@ local string = {
module("vicious.widgets.cpu")
-- Initialise function tables
-- Initialize function tables
local cpu_usage = {}
local cpu_total = {}
local cpu_active = {}

View File

@ -16,7 +16,7 @@ local helpers = require("vicious.helpers")
module("vicious.widgets.dio")
-- Initialise function tables
-- Initialize function tables
local disk_usage = {}
local disk_total = {}
-- Variable definitions

View File

@ -38,16 +38,15 @@ local rss = {
-- Default is all unread
local feed = rss.unread
local mail = {
["{count}"] = 0,
["{subject}"] = "N/A"
}
-- }}}
-- {{{ Gmail widget type
local function worker(format, warg)
local mail = {
["{count}"] = 0,
["{subject}"] = "N/A"
}
-- Get info from the Gmail atom feed
local f = io.popen("curl --connect-timeout 1 -m 3 -fsn " .. feed[1])

View File

@ -16,6 +16,7 @@ require("vicious.widgets.mem")
require("vicious.widgets.os")
require("vicious.widgets.fs")
require("vicious.widgets.dio")
require("vicious.widgets.raid")
require("vicious.widgets.hddtemp")
require("vicious.widgets.net")
require("vicious.widgets.wifi")

View File

@ -16,13 +16,13 @@ local helpers = require("vicious.helpers")
module("vicious.widgets.mbox")
-- Initialize variables
local subject = "N/A"
-- {{{ Mailbox widget type
local function worker(format, warg)
if not warg then return end
-- Default value
local subject = "N/A"
-- mbox could be huge, get a 30kb chunk from EOF
if type(warg) ~= "table" then mbox = warg end
-- * attachment could be much bigger than 30kb

View File

@ -18,7 +18,7 @@ module("vicious.widgets.mboxc")
local function worker(format, warg)
if not warg then return end
-- Initialise counters
-- Initialize counters
local count = { old = 0, total = 0, new = 0 }
-- Get data from mbox files

View File

@ -18,7 +18,7 @@ module("vicious.widgets.mdir")
local function worker(format, warg)
if not warg then return end
-- Initialise counters
-- Initialize counters
local count = { new = 0, cur = 0 }
for i=1, #warg do

View File

@ -18,7 +18,7 @@ local helpers = require("vicious.helpers")
module("vicious.widgets.net")
-- Initialise function tables
-- Initialize function tables
local nets = {}
-- Variable definitions
local unit = { ["b"] = 1, ["kb"] = 1024,

View File

@ -28,7 +28,7 @@ local function worker(format, warg)
local soon = today + 24 * 3600 * 3 -- 3 days ahead is close
local future = today + 24 * 3600 * 7 -- 7 days ahead is maximum
-- Initialise counters
-- Initialize counters
local count = { past = 0, today = 0, soon = 0, future = 0 }
-- Get data from agenda files

View File

@ -18,13 +18,15 @@ module("vicious.widgets.pkg")
local function worker(format, warg)
if not warg then return end
-- Initialise counters
-- Initialize counters
local updates = 0
local manager = {
["Arch"] = { cmd = "pacman -Qu" },
["Arch S"] = { cmd = "yes | pacman -Sup", sub = 2 },
["Debian"] = { cmd = "apt-show-versions -u -b" },
["Fedora"] = { cmd = "yum list updates", sub = 3 }
["Ubuntu"] = { cmd = "aptitude search '~U'" },
["Fedora"] = { cmd = "yum list updates", sub = 3 },
["Mandriva"]={ cmd = "urpmq --auto-select" }
}
-- Check if updates are available

57
widgets/raid.lua Normal file
View File

@ -0,0 +1,57 @@
-----------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Hagen Schink <troja84@googlemail.com>
-----------------------------------------------------
-- {{{ Grab environment
local io = { lines = io.lines }
local setmetatable = setmetatable
local string = {
len = string.len,
sub = string.sub,
match = string.match,
gmatch = string.gmatch
}
-- }}}
-- Raid: provides state information for a requested RAID array
module("vicious.widgets.raid")
-- Initialize function tables
local mddev = {}
-- {{{ RAID widget type
local function worker(format, warg)
if not warg then return end
mddev[warg] = {
["found"] = false,
["active"] = 0,
["assigned"] = 0
}
-- Linux manual page: md(4)
for line in io.lines("/proc/mdstat") do
if mddev[warg]["found"] then
local updev = string.match(line, "%[[_U]+%]")
for i in string.gmatch(updev, "U") do
mddev[warg]["active"] = mddev[warg]["active"] + 1
end
break
elseif string.sub(line, 1, string.len(warg)) == warg then
mddev[warg]["found"] = true
for i in string.gmatch(line, "%[%d%]") do
mddev[warg]["assigned"] = mddev[warg]["assigned"] + 1
end
end
end
return {mddev[warg]["assigned"], mddev[warg]["active"]}
end
-- }}}
setmetatable(_M, { __call = function(_, ...) return worker(...) end })

View File

@ -27,8 +27,7 @@ local function worker(format)
local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
string.match(proc.loadavg, "([%d]*%.[%d]*)%s([%d]*%.[%d]*)%s([%d]*%.[%d]*)")
string.match(proc.loadavg, "([%d%.]+)[%s]([%d%.]+)[%s]([%d%.]+)")
return {up_d, up_h, up_m, l1, l5, l15}
end
-- }}}

View File

@ -17,24 +17,24 @@ local helpers = require("vicious.helpers")
module("vicious.widgets.weather")
-- Initialize function tables
local weather = {
["{city}"] = "N/A",
["{wind}"] = "N/A",
["{windmph}"] = "N/A",
["{windkmh}"] = "N/A",
["{sky}"] = "N/A",
["{weather}"] = "N/A",
["{tempf}"] = "N/A",
["{tempc}"] = "N/A",
["{humid}"] = "N/A",
["{press}"] = "N/A"
}
-- {{{ Weather widget type
local function worker(format, warg)
if not warg then return end
-- Default values
local weather = {
["{city}"] = "N/A",
["{wind}"] = "N/A",
["{windmph}"] = "N/A",
["{windkmh}"] = "N/A",
["{sky}"] = "N/A",
["{weather}"] = "N/A",
["{tempf}"] = "N/A",
["{tempc}"] = "N/A",
["{humid}"] = "N/A",
["{press}"] = "N/A"
}
-- Get weather forceast by the station ICAO code, from:
-- * US National Oceanic and Atmospheric Administration
local noaa = "http://weather.noaa.gov/pub/data/observations/metar/decoded/"

View File

@ -21,20 +21,20 @@ local string = {
module("vicious.widgets.wifi")
-- Initialize function tables
local winfo = {
["{ssid}"] = "N/A",
["{mode}"] = "N/A",
["{chan}"] = 0,
["{rate}"] = 0,
["{link}"] = 0,
["{sign}"] = 0
}
-- {{{ Wireless widget type
local function worker(format, warg)
if not warg then return end
-- Default values
local winfo = {
["{ssid}"] = "N/A",
["{mode}"] = "N/A",
["{chan}"] = 0,
["{rate}"] = 0,
["{link}"] = 0,
["{sign}"] = 0
}
-- Get data from iwconfig where available
local iwconfig = "/sbin/iwconfig"
local f = io.open(iwconfig, "rb")