aboutsummaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 03:37:40 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 03:37:40 +0100
commit4dad2e360c1c464feef9a8aaff6e96a7636c54b7 (patch)
tree03290f705cef2ec761a0a1ee46b3bc38cb08e0ea /widgets
parent237470c8f45190b213e3a173ce6ae1a74b3e11fe (diff)
downloadvicious-legacy-4dad2e360c1c464feef9a8aaff6e96a7636c54b7.tar.xz
API: missing warg should not break awesome
Diffstat (limited to 'widgets')
-rw-r--r--widgets/bat.lua7
-rw-r--r--widgets/cpufreq.lua6
-rw-r--r--widgets/dio.lua2
-rw-r--r--widgets/fs.lua6
-rw-r--r--widgets/hddtemp.lua8
-rw-r--r--widgets/mbox.lua6
-rw-r--r--widgets/mboxc.lua2
-rw-r--r--widgets/mdir.lua2
-rw-r--r--widgets/org.lua2
-rw-r--r--widgets/pkg.lua6
-rw-r--r--widgets/thermal.lua2
-rw-r--r--widgets/volume.lua2
-rw-r--r--widgets/weather.lua6
-rw-r--r--widgets/wifi.lua6
14 files changed, 43 insertions, 20 deletions
diff --git a/widgets/bat.lua b/widgets/bat.lua
index d6e3e6b..9fc438d 100644
--- a/widgets/bat.lua
+++ b/widgets/bat.lua
@@ -20,9 +20,10 @@ module("vicious.widgets.bat")
-- {{{ Battery widget type
-local function worker(format, batid)
- -- Apple PMU and ACPI/procfs battery widgets are in the [contrib] branch
- local battery = helpers.pathtotable("/sys/class/power_supply/" .. batid)
+local function worker(format, warg)
+ if not warg then return end
+
+ local battery = helpers.pathtotable("/sys/class/power_supply/"..warg)
local battery_state = {
["Full\n"] = "↯",
["Unknown\n"] = "⌁",
diff --git a/widgets/cpufreq.lua b/widgets/cpufreq.lua
index 7f60f5a..f7c6a27 100644
--- a/widgets/cpufreq.lua
+++ b/widgets/cpufreq.lua
@@ -16,8 +16,10 @@ module("vicious.widgets.cpufreq")
-- {{{ CPU frequency widget type
-local function worker(format, cpuid)
- local cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..cpuid.."/cpufreq")
+local function worker(format, warg)
+ if not warg then return end
+
+ local cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq")
local governor_state = {
["ondemand\n"] = "↯",
["powersave\n"] = "⌁",
diff --git a/widgets/dio.lua b/widgets/dio.lua
index 9731d57..64a56e1 100644
--- a/widgets/dio.lua
+++ b/widgets/dio.lua
@@ -24,6 +24,8 @@ local unit = { ["s"] = 1, ["kb"] = 2, ["mb"] = 2048 }
-- {{{ Disk I/O widget type
local function worker(format, disk)
+ if not disk then return end
+
local disk_lines = { [disk] = {} }
local disk_stats = helpers.pathtotable("/sys/block/" .. disk)
local disk_queue = helpers.pathtotable("/sys/block/" .. disk .. "/queue")
diff --git a/widgets/fs.lua b/widgets/fs.lua
index a85b903..4490c91 100644
--- a/widgets/fs.lua
+++ b/widgets/fs.lua
@@ -21,12 +21,12 @@ module("vicious.widgets.fs")
local unit = { ["mb"] = 1024, ["gb"] = 1024^2 }
-- {{{ Filesystem widget type
-local function worker(format, nfs)
+local function worker(format, warg)
-- Fallback to listing local filesystems
- if nfs then nfs = "" else nfs = "-l" end
+ if warg then warg = "" else warg = "-l" end
-- Get (non-localized)data from df
- local f = io.popen("LC_ALL=C df -kP " .. nfs)
+ local f = io.popen("LC_ALL=C df -kP " .. warg)
local fs_info = {}
for line in f:lines() do -- Match: (size) (used)(avail)(use%) (mount)
diff --git a/widgets/hddtemp.lua b/widgets/hddtemp.lua
index 6fcd05f..e5ab96d 100644
--- a/widgets/hddtemp.lua
+++ b/widgets/hddtemp.lua
@@ -16,12 +16,12 @@ module("vicious.widgets.hddtemp")
-- {{{ HDD Temperature widget type
-local function worker(format, port)
- -- Fallback to default hddtemp port
- if port == nil then port = 7634 end
+local function worker(format, warg)
+ -- Fallback to default hddtemp warg
+ if warg == nil then warg = 7634 end
-- Get info from the hddtemp daemon
- 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:"..warg)
local hdd_temp = {}
for line in f:lines() do
diff --git a/widgets/mbox.lua b/widgets/mbox.lua
index eca5403..efd3a42 100644
--- a/widgets/mbox.lua
+++ b/widgets/mbox.lua
@@ -18,9 +18,11 @@ module("vicious.widgets.mbox")
-- {{{ Mailbox widget type
local function worker(format, warg)
- if type(warg) ~= "table" then mbox = warg end
+ if not warg then return end
+
-- mbox could be huge, get a 30kb chunk from EOF
- -- * attachments could be much bigger than this
+ if type(warg) ~= "table" then mbox = warg end
+ -- * attachment could be much bigger than 30kb
local f = io.open(mbox or warg[1])
f:seek("end", -30720)
local txt = f:read("*all")
diff --git a/widgets/mboxc.lua b/widgets/mboxc.lua
index c5f694c..6de1066 100644
--- a/widgets/mboxc.lua
+++ b/widgets/mboxc.lua
@@ -16,6 +16,8 @@ module("vicious.widgets.mboxc")
-- {{{ Mbox count widget type
local function worker(format, warg)
+ if not warg then return end
+
-- Initialise counters
local count = { old = 0, total = 0, new = 0 }
diff --git a/widgets/mdir.lua b/widgets/mdir.lua
index 858a9b1..94522e7 100644
--- a/widgets/mdir.lua
+++ b/widgets/mdir.lua
@@ -16,6 +16,8 @@ module("vicious.widgets.mdir")
-- {{{ Maildir widget type
local function worker(format, warg)
+ if not warg then return end
+
-- Initialise counters
local count = { new = 0, cur = 0 }
diff --git a/widgets/org.lua b/widgets/org.lua
index 8764e3a..e6c622e 100644
--- a/widgets/org.lua
+++ b/widgets/org.lua
@@ -21,6 +21,8 @@ module("vicious.widgets.org")
-- {{{ OrgMode widget type
local function worker(format, warg)
+ if not warg then return end
+
-- 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
diff --git a/widgets/pkg.lua b/widgets/pkg.lua
index fa2375b..d514e33 100644
--- a/widgets/pkg.lua
+++ b/widgets/pkg.lua
@@ -15,7 +15,9 @@ module("vicious.widgets.pkg")
-- {{{ Packages widget type
-local function worker(format, dist)
+local function worker(format, warg)
+ if not warg then return end
+
-- Initialise counters
local updates = 0
local manager = {
@@ -26,7 +28,7 @@ local function worker(format, dist)
}
-- Check if updates are available
- local pkg = manager[dist]
+ local pkg = manager[warg]
local f = io.popen(pkg.cmd)
for line in f:lines() do
diff --git a/widgets/thermal.lua b/widgets/thermal.lua
index 9768c57..6ba8c69 100644
--- a/widgets/thermal.lua
+++ b/widgets/thermal.lua
@@ -18,6 +18,8 @@ module("vicious.widgets.thermal")
-- {{{ Thermal widget type
local function worker(format, warg)
+ if not warg then return end
+
local zone = { -- Known temperature data sources
["sys"] = {"/sys/class/thermal/", file = "temp", div = 1000},
["core"] = {"/sys/devices/platform/", file = "temp1_input",div = 1000},
diff --git a/widgets/volume.lua b/widgets/volume.lua
index 42f72e4..8f34609 100644
--- a/widgets/volume.lua
+++ b/widgets/volume.lua
@@ -17,6 +17,8 @@ module("vicious.widgets.volume")
-- {{{ Volume widget type
local function worker(format, warg)
+ if not warg then return end
+
local mixer_state = {
["on"] = "♫", -- "",
["off"] = "♩" -- "M"
diff --git a/widgets/weather.lua b/widgets/weather.lua
index effa138..7a114c0 100644
--- a/widgets/weather.lua
+++ b/widgets/weather.lua
@@ -18,7 +18,9 @@ module("vicious.widgets.weather")
-- {{{ Weather widget type
-local function worker(format, station)
+local function worker(format, warg)
+ if not warg then return end
+
-- Default values
local weather = {
["{city}"] = "N/A",
@@ -36,7 +38,7 @@ local function worker(format, station)
-- 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/"
- local f = io.popen("curl --connect-timeout 1 -fsm 3 "..noaa..station..".TXT")
+ local f = io.popen("curl --connect-timeout 1 -fsm 3 "..noaa..warg..".TXT")
local ws = f:read("*all")
f:close()
diff --git a/widgets/wifi.lua b/widgets/wifi.lua
index 65ffb79..ca578d1 100644
--- a/widgets/wifi.lua
+++ b/widgets/wifi.lua
@@ -22,7 +22,9 @@ module("vicious.widgets.wifi")
-- {{{ Wireless widget type
-local function worker(format, iface)
+local function worker(format, warg)
+ if not warg then return end
+
-- Default values
local winfo = {
["{ssid}"] = "N/A",
@@ -41,7 +43,7 @@ local function worker(format, iface)
else
f:close()
end
- local f = io.popen(iwconfig .." ".. iface .. " 2>&1")
+ local f = io.popen(iwconfig .." ".. warg .. " 2>&1")
local iw = f:read("*all")
f:close()