Merge branch 'master' of http://git.sysphere.org/vicious
Conflicts: contrib/README
This commit is contained in:
commit
b0e631f8d6
63
README
63
README
|
@ -1,16 +1,16 @@
|
||||||
Vicious
|
Vicious
|
||||||
-------
|
-------
|
||||||
Vicious is a modular widget library for the "awesome" window manager,
|
Vicious is a modular widget library for window managers, but mostly
|
||||||
derived from the "Wicked" widget library. It has some of the old
|
catering to users of the "awesome" window manager. It was derived from
|
||||||
Wicked widget types, a few of them rewritten, and a good number of new
|
the old "Wicked" widget library, and has some of the old Wicked widget
|
||||||
ones:
|
types, a few of them rewritten, and a good number of new ones:
|
||||||
|
|
||||||
- http://git.sysphere.org/vicious/about/
|
- http://git.sysphere.org/vicious/about/
|
||||||
|
|
||||||
Vicious widget types are a framework for creating your own awesome
|
Vicious widget types are a framework for creating your own
|
||||||
widgets. Vicious contains modules that gather data about your system,
|
widgets. Vicious contains modules that gather data about your system,
|
||||||
and a few helper functions that make it easier to register timers,
|
and a few "awesome" helper functions that make it easier to register
|
||||||
suspend widgets and so on.
|
timers, suspend widgets and so on.
|
||||||
|
|
||||||
For now Vicious doesn't depend on any third party Lua libraries, to
|
For now Vicious doesn't depend on any third party Lua libraries, to
|
||||||
make it easier to install and use. That means some system utilities
|
make it easier to install and use. That means some system utilities
|
||||||
|
@ -24,8 +24,22 @@ are used instead, where available:
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
To use vicious move it to your awesome configuration directory in
|
When provided by an operating system package, or installed from source
|
||||||
$XDG_CONFIG_HOME (usually ~/.config):
|
into the Lua library path Vicious can be used as a regular Lua
|
||||||
|
library, to be used stand-alone or to feed widgets of any window
|
||||||
|
manager (ie. Ion, WMII). It is compatible with both Lua v5.1 and v5.2.
|
||||||
|
|
||||||
|
$ lua
|
||||||
|
> widgets = require("vicious.widgets")
|
||||||
|
> print(widgets.volume(nil, "Master")[1])
|
||||||
|
100
|
||||||
|
|
||||||
|
|
||||||
|
Usage within Awesome
|
||||||
|
--------------------
|
||||||
|
To use Vicious with Awesome, install the package from your operating
|
||||||
|
system provider, or download the source code and move it to your
|
||||||
|
awesome configuration directory in $XDG_CONFIG_HOME (usually ~/.config):
|
||||||
|
|
||||||
$ mv vicious $XDG_CONFIG_HOME/awesome/
|
$ mv vicious $XDG_CONFIG_HOME/awesome/
|
||||||
|
|
||||||
|
@ -373,7 +387,7 @@ file with their GPG key. Trough the GPG Passphrase Agent they could
|
||||||
then decrypt the file transparently while their session is active.
|
then decrypt the file transparently while their session is active.
|
||||||
|
|
||||||
|
|
||||||
Usage examples (for awesome v3.4)
|
Usage examples
|
||||||
---------------------------------
|
---------------------------------
|
||||||
Start with a simple widget, like date. Then build your setup from
|
Start with a simple widget, like date. Then build your setup from
|
||||||
there, one widget at a time. Also remember that besides creating and
|
there, one widget at a time. Also remember that besides creating and
|
||||||
|
@ -381,14 +395,14 @@ registering widgets you have to add them to a wibox (statusbar) in
|
||||||
order to actually display them.
|
order to actually display them.
|
||||||
|
|
||||||
Date widget
|
Date widget
|
||||||
datewidget = widget({ type = "textbox" })
|
datewidget = wibox.widget.textbox()
|
||||||
vicious.register(datewidget, vicious.widgets.date, "%b %d, %R")
|
vicious.register(datewidget, vicious.widgets.date, "%b %d, %R")
|
||||||
|
|
||||||
- updated every 2 seconds (the default interval), uses standard
|
- updated every 2 seconds (the default interval), uses standard
|
||||||
date sequences as the format string
|
date sequences as the format string
|
||||||
|
|
||||||
Memory widget
|
Memory widget
|
||||||
memwidget = widget({ type = "textbox" })
|
memwidget = wibox.widget.textbox()
|
||||||
vicious.cache(vicious.widgets.mem)
|
vicious.cache(vicious.widgets.mem)
|
||||||
vicious.register(memwidget, vicious.widgets.mem, "$1 ($2MB/$3MB)", 13)
|
vicious.register(memwidget, vicious.widgets.mem, "$1 ($2MB/$3MB)", 13)
|
||||||
|
|
||||||
|
@ -396,7 +410,7 @@ Memory widget
|
||||||
values and enables caching of this widget type
|
values and enables caching of this widget type
|
||||||
|
|
||||||
HDD temperature widget
|
HDD temperature widget
|
||||||
hddtempwidget = widget({ type = "textbox" })
|
hddtempwidget = wibox.widget.textbox()
|
||||||
vicious.register(hddtempwidget, vicious.widgets.hddtemp, "${/dev/sda} °C", 19)
|
vicious.register(hddtempwidget, vicious.widgets.hddtemp, "${/dev/sda} °C", 19)
|
||||||
|
|
||||||
- updated every 19 seconds, requests the temperature level of the
|
- updated every 19 seconds, requests the temperature level of the
|
||||||
|
@ -404,7 +418,7 @@ HDD temperature widget
|
||||||
not provide the port argument so default port is used
|
not provide the port argument so default port is used
|
||||||
|
|
||||||
Mbox widget
|
Mbox widget
|
||||||
mboxwidget = widget({ type = "textbox" })
|
mboxwidget = wibox.widget.textbox()
|
||||||
vicious.register(mboxwidget, vicious.widgets.mbox, "$1", 5, "/home/user/mail/Inbox")
|
vicious.register(mboxwidget, vicious.widgets.mbox, "$1", 5, "/home/user/mail/Inbox")
|
||||||
|
|
||||||
- updated every 5 seconds, provides full path to the mbox as an
|
- updated every 5 seconds, provides full path to the mbox as an
|
||||||
|
@ -417,8 +431,8 @@ Battery widget
|
||||||
batwidget:set_vertical(true)
|
batwidget:set_vertical(true)
|
||||||
batwidget:set_background_color("#494B4F")
|
batwidget:set_background_color("#494B4F")
|
||||||
batwidget:set_border_color(nil)
|
batwidget:set_border_color(nil)
|
||||||
batwidget:set_color("#AECF96")
|
batwidget:set_color({ type = "linear", from = { 0, 0 }, to = { 0, 10 },
|
||||||
batwidget:set_gradient_colors({ "#AECF96", "#88A175", "#FF5656" })
|
stops = { { 0, "#AECF96" }, { 0.5, "#88A175" }, { 1, "#FF5656" }})
|
||||||
vicious.register(batwidget, vicious.widgets.bat, "$2", 61, "BAT0")
|
vicious.register(batwidget, vicious.widgets.bat, "$2", 61, "BAT0")
|
||||||
|
|
||||||
- updated every 61 seconds, requests the current battery charge
|
- updated every 61 seconds, requests the current battery charge
|
||||||
|
@ -429,8 +443,8 @@ CPU usage widget
|
||||||
cpuwidget = awful.widget.graph()
|
cpuwidget = awful.widget.graph()
|
||||||
cpuwidget:set_width(50)
|
cpuwidget:set_width(50)
|
||||||
cpuwidget:set_background_color("#494B4F")
|
cpuwidget:set_background_color("#494B4F")
|
||||||
cpuwidget:set_color("#FF5656")
|
cpuwidget:set_color({ type = "linear", from = { 0, 0 }, to = { 50, 0 },
|
||||||
cpuwidget:set_gradient_colors({ "#FF5656", "#88A175", "#AECF96" })
|
stops = { { 0, "#FF5656" }, { 0.5, "#88A175" }, { 1, "#AECF96" }})
|
||||||
vicious.register(cpuwidget, vicious.widgets.cpu, "$1", 3)
|
vicious.register(cpuwidget, vicious.widgets.cpu, "$1", 3)
|
||||||
|
|
||||||
- updated every 3 seconds, feeds the graph with total usage
|
- updated every 3 seconds, feeds the graph with total usage
|
||||||
|
@ -454,7 +468,7 @@ second argument, and will return the text/data to be used for the
|
||||||
widget.
|
widget.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
mpdwidget = widget({ type = "textbox" })
|
mpdwidget = wibox.widget.textbox()
|
||||||
vicious.register(mpdwidget, vicious.widgets.mpd,
|
vicious.register(mpdwidget, vicious.widgets.mpd,
|
||||||
function (widget, args)
|
function (widget, args)
|
||||||
if args["{state}"] == "Stop" then return ""
|
if args["{state}"] == "Stop" then return ""
|
||||||
|
@ -467,7 +481,7 @@ Example
|
||||||
seconds (the default interval)
|
seconds (the default interval)
|
||||||
|
|
||||||
Example
|
Example
|
||||||
uptimewidget = widget({ type = "textbox" })
|
uptimewidget = wibox.widget.textbox()
|
||||||
vicious.register(uptimewidget, vicious.widgets.uptime,
|
vicious.register(uptimewidget, vicious.widgets.uptime,
|
||||||
function (widget, args)
|
function (widget, args)
|
||||||
return string.format("Uptime: %2dd %02d:%02d ", args[1], args[2], args[3])
|
return string.format("Uptime: %2dd %02d:%02d ", args[1], args[2], args[3])
|
||||||
|
@ -482,9 +496,10 @@ textbox widgets by changing their .width field (by default width is
|
||||||
automatically adapted to text width).
|
automatically adapted to text width).
|
||||||
|
|
||||||
Example
|
Example
|
||||||
uptimewidget = widget({ type = "textbox" })
|
uptimewidget = wibox.widget.textbox()
|
||||||
uptimewidget.width, uptimewidget.align = 50, "right"
|
uptimewidget:set_align("right")
|
||||||
vicious.register(uptimewidget, vicious.widgets.uptime, "$1 $2:$3", 61)
|
vicious.register(uptimewidget, vicious.widgets.uptime, "$1 $2:$3", 61)
|
||||||
|
uptimewidget = wibox.layout.constraint(uptimewidget, "exact", 50, nil)
|
||||||
|
|
||||||
- forces a fixed width of 50px to the uptime widget, and aligns its
|
- forces a fixed width of 50px to the uptime widget, and aligns its
|
||||||
text to the right
|
text to the right
|
||||||
|
@ -495,7 +510,7 @@ color index arguments elegantly. But they are not unusable, far from
|
||||||
it.
|
it.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
ctext = widget({ type = "textbox"})
|
ctext = wibox.widget.textbox()
|
||||||
cgraph = awful.widget.graph()
|
cgraph = awful.widget.graph()
|
||||||
cgraph:set_width(100):set_height(20)
|
cgraph:set_width(100):set_height(20)
|
||||||
cgraph:set_stack(true):set_max_value(100)
|
cgraph:set_stack(true):set_max_value(100)
|
||||||
|
@ -516,7 +531,7 @@ A lot of users are not happy with default symbols used in volume,
|
||||||
battery, cpufreq and other widget types. You can use your own symbols
|
battery, cpufreq and other widget types. You can use your own symbols
|
||||||
without any need to modify modules.
|
without any need to modify modules.
|
||||||
|
|
||||||
volumewidget = widget({ type = "textbox"})
|
volumewidget = wibox.widget.textbox()
|
||||||
vicious.register(volumewidget, vicious.widgets.volume,
|
vicious.register(volumewidget, vicious.widgets.volume,
|
||||||
function(widget, args)
|
function(widget, args)
|
||||||
local label = { ["♫"] = "O", ["♩"] = "M" }
|
local label = { ["♫"] = "O", ["♩"] = "M" }
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
Contrib
|
Contrib
|
||||||
-------
|
-------
|
||||||
Contrib widgets are extra widgets you can use. Some are for less
|
Contrib libraries, or widget types, are extra snippets of code you can
|
||||||
common hardware, and other were contributed by Vicious users. The
|
use. Some are for less common hardware, and other were contributed by
|
||||||
contrib directory also holds widget types that were obsoleted or
|
Vicious users. The contrib directory also holds widget types that were
|
||||||
rewritten. Contrib widgets will not be imported by init unless you
|
obsoleted or rewritten. Contrib widgets will not be imported by init
|
||||||
explicitly enable it, or load them in your rc.lua.
|
unless you explicitly enable it, or load them in your rc.lua.
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage within Awesome
|
||||||
-----
|
--------------------
|
||||||
To use contrib widgets uncomment the line that loads them in
|
To use contrib widgets uncomment the line that loads them in
|
||||||
init.lua. Or you can load them in your rc.lua after you require
|
init.lua. Or you can load them in your rc.lua after you require
|
||||||
Vicious:
|
Vicious:
|
||||||
|
@ -36,6 +36,14 @@ vicious.contrib.ac
|
||||||
- if AC is connected, $1 returns "On", if not it returns "Off",
|
- if AC is connected, $1 returns "On", if not it returns "Off",
|
||||||
if AC doesn't exist, $1 is "N/A"
|
if AC doesn't exist, $1 is "N/A"
|
||||||
|
|
||||||
|
vicious.contrib.ati
|
||||||
|
- provides various info about ATI GPU status
|
||||||
|
- takes card ID as an argument, i.e. "card0" (and where possible,
|
||||||
|
uses debugfs to gather data on radeon power management)
|
||||||
|
- returns a table with string keys: {method}, {dpm_state},
|
||||||
|
{dpm_perf_level}, {profile}, {engine_clock mhz}, {engine_clock khz},
|
||||||
|
{memory_clock mhz}, {memory_clock khz}, {voltage v}, {voltage mv}
|
||||||
|
|
||||||
vicious.contrib.batacpi
|
vicious.contrib.batacpi
|
||||||
-
|
-
|
||||||
|
|
||||||
|
@ -62,6 +70,12 @@ vicious.contrib.netcfg
|
||||||
vicious.contrib.net
|
vicious.contrib.net
|
||||||
-
|
-
|
||||||
|
|
||||||
|
vicious.contrib.openweather
|
||||||
|
- provides weather information for a requested city
|
||||||
|
- takes OpenWeatherMap city ID as an argument, i.e. "1275339"
|
||||||
|
- returns a table with string keys: {city}, {wind deg}, {wind aim},
|
||||||
|
{wind kmh}, {wind mps}, {sky}, {weather}, {temp c}, {humid}, {press}
|
||||||
|
|
||||||
vicious.contrib.ossvol
|
vicious.contrib.ossvol
|
||||||
-
|
-
|
||||||
|
|
||||||
|
@ -106,9 +120,11 @@ vicious.contrib.buildbot
|
||||||
- <buildNumber> colors: red - failed, green - successful, yellow - in progress
|
- <buildNumber> colors: red - failed, green - successful, yellow - in progress
|
||||||
- it depends on lua json parser (e.g. liblua5.1-json on Ubuntu 12.04)
|
- it depends on lua json parser (e.g. liblua5.1-json on Ubuntu 12.04)
|
||||||
|
|
||||||
|
|
||||||
Usage examples
|
Usage examples
|
||||||
--------------
|
---------------------------------
|
||||||
Pulse Audio widget
|
Pulse Audio widget
|
||||||
|
vol = wibox.widget.textbox()
|
||||||
vicious.register(vol, vicious.contrib.pulse, " $1%", 2, "alsa_output.pci-0000_00_1b.0.analog-stereo")
|
vicious.register(vol, vicious.contrib.pulse, " $1%", 2, "alsa_output.pci-0000_00_1b.0.analog-stereo")
|
||||||
vol:buttons(awful.util.table.join(
|
vol:buttons(awful.util.table.join(
|
||||||
awful.button({ }, 1, function () awful.util.spawn("pavucontrol") end),
|
awful.button({ }, 1, function () awful.util.spawn("pavucontrol") end),
|
||||||
|
@ -117,7 +133,7 @@ Pulse Audio widget
|
||||||
))
|
))
|
||||||
|
|
||||||
Buildbot widget
|
Buildbot widget
|
||||||
local buildbotwidget = widget({ type = "textbox" })
|
buildbotwidget = wibox.widget.textbox()
|
||||||
local buildbotwidget_warg = {
|
local buildbotwidget_warg = {
|
||||||
{builder="coverage", url="http://buildbot.buildbot.net"},
|
{builder="coverage", url="http://buildbot.buildbot.net"},
|
||||||
{builder="tarball-slave", url="http://buildbot.buildbot.net"}
|
{builder="tarball-slave", url="http://buildbot.buildbot.net"}
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
---------------------------------------------------
|
||||||
|
-- Licensed under the GNU General Public License v2
|
||||||
|
-- * (c) 2013, NormalRa <normalrawr gmail com>
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local tonumber = tonumber
|
||||||
|
local io = { open = io.open }
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
local string = {
|
||||||
|
sub = string.sub,
|
||||||
|
match = string.match,
|
||||||
|
gmatch = string.gmatch
|
||||||
|
}
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- ATI: provides various info about ATI GPU status
|
||||||
|
-- vicious.widgets.ati
|
||||||
|
local ati = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- {{{ Define variables
|
||||||
|
local _units = { clock = { ["khz"] = 1, ["mhz"] = 1000 },
|
||||||
|
voltage = { ["v"] = 1, ["mv"] = 1000 } }
|
||||||
|
local _reps = {
|
||||||
|
["sclk"] = { name = "engine_clock", units = _units.clock, mul = 10 },
|
||||||
|
["mclk"] = { name = "memory_clock", units = _units.clock, mul = 10 },
|
||||||
|
["vddc"] = { name = "voltage", units = _units.voltage },
|
||||||
|
["voltage"] = { name = "voltage", units = _units.voltage },
|
||||||
|
["current engine clock"] = { name = "engine_clock", units = _units.clock },
|
||||||
|
["current memory clock"] = { name = "memory_clock", units = _units.clock }
|
||||||
|
}
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ ATI widget type
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
local pm = helpers.pathtotable("/sys/class/drm/"..warg.."/device")
|
||||||
|
local _data = {}
|
||||||
|
|
||||||
|
-- Get power info
|
||||||
|
_data["{method}"] =
|
||||||
|
pm.power_method and string.sub(pm.power_method, 1, -2) or "N/A"
|
||||||
|
_data["{dpm_state}"] =
|
||||||
|
pm.power_dpm_state and string.sub(pm.power_dpm_state, 1, -2) or "N/A"
|
||||||
|
_data["{dpm_perf_level}"] =
|
||||||
|
pm.power_dpm_force_performance_level and
|
||||||
|
string.sub(pm.power_dpm_force_performance_level, 1, -2) or "N/A"
|
||||||
|
_data["{profile}"] =
|
||||||
|
pm.power_profile and string.sub(pm.power_profile, 1, -2) or "N/A"
|
||||||
|
|
||||||
|
local f = io.open("/sys/kernel/debug/dri/64/radeon_pm_info", "r")
|
||||||
|
if f then -- Get ATI info from the debug filesystem
|
||||||
|
for line in f:lines() do
|
||||||
|
for k, unit in string.gmatch(line, "(%a+[%a%s]*):[%s]+([%d]+)") do
|
||||||
|
unit = tonumber(unit)
|
||||||
|
|
||||||
|
_data["{dpm_power_level}"] = -- DPM active?
|
||||||
|
tonumber(string.match(line, "power level ([%d])")) or "N/A"
|
||||||
|
|
||||||
|
if _reps[k] then
|
||||||
|
for u, v in pairs(_reps[k].units) do
|
||||||
|
_data["{".._reps[k].name.." "..u.."}"] =
|
||||||
|
(unit * (_reps[k].mul or 1)) / v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
return _data
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(ati, { __call = function(_, ...) return worker(...) end })
|
|
@ -0,0 +1,94 @@
|
||||||
|
---------------------------------------------------
|
||||||
|
-- Licensed under the GNU General Public License v2
|
||||||
|
-- * (c) 2013, NormalRa <normalrawr gmail com>
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local tonumber = tonumber
|
||||||
|
local io = { popen = io.popen }
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local string = { match = string.match }
|
||||||
|
local math = {
|
||||||
|
ceil = math.ceil,
|
||||||
|
floor = math.floor
|
||||||
|
}
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- Openweather: provides weather information for a requested station
|
||||||
|
-- vicious.widgets.openweather
|
||||||
|
local openweather = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- Initialize function tables
|
||||||
|
local _wdirs = { "N", "NE", "E", "SE", "S", "SW", "W", "NW", "N" }
|
||||||
|
local _wdata = {
|
||||||
|
["{city}"] = "N/A",
|
||||||
|
["{wind deg}"] = "N/A",
|
||||||
|
["{wind aim}"] = "N/A",
|
||||||
|
["{wind mps}"] = "N/A",
|
||||||
|
["{wind kmh}"] = "N/A",
|
||||||
|
["{sky}"] = "N/A",
|
||||||
|
["{weather}"] = "N/A",
|
||||||
|
["{temp c}"] = "N/A",
|
||||||
|
["{humid}"] = "N/A",
|
||||||
|
["{press}"] = "N/A"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- {{{ Openweather widget type
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
-- Get weather forceast using the city ID code, from:
|
||||||
|
-- * OpenWeatherMap.org
|
||||||
|
local openweather = "http://api.openweathermap.org/data/2.5/weather?id="..warg.."&mode=json&units=metric"
|
||||||
|
local f = io.popen("curl --connect-timeout 1 -fsm 3 '"..openweather.."'")
|
||||||
|
local ws = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
-- Check if there was a timeout or a problem with the station
|
||||||
|
if ws == nil then return _wdata end
|
||||||
|
|
||||||
|
_wdata["{city}"] = -- City name
|
||||||
|
string.match(ws, '"name":"([%a%s%-]+)"') or _wdata["{city}"]
|
||||||
|
_wdata["{wind deg}"] = -- Wind degrees
|
||||||
|
string.match(ws, '"deg":([%d]+)') or _wdata["{wind deg}"]
|
||||||
|
_wdata["{wind mps}"] = -- Wind speed in meters per second
|
||||||
|
string.match(ws, '"speed":([%d%.]+)') or _wdata["{wind mps}"]
|
||||||
|
_wdata["{sky}"] = -- Sky conditions
|
||||||
|
string.match(ws, '"main":"([%a]+)"') or _wdata["{sky}"]
|
||||||
|
_wdata["{weather}"] = -- Weather description
|
||||||
|
string.match(ws, '"description":"([%a%s]+)"') or _wdata["{weather}"]
|
||||||
|
_wdata["{temp c}"] = -- Temperature in celsius
|
||||||
|
string.match(ws, '"temp":([%-]?[%d%.]+)') or _wdata["{temp c}"]
|
||||||
|
_wdata["{humid}"] = -- Relative humidity in percent
|
||||||
|
string.match(ws, '"humidity":([%d]+)') or _wdata["{humid}"]
|
||||||
|
_wdata["{press}"] = -- Pressure in hPa
|
||||||
|
string.match(ws, '"pressure":([%d%.]+)') or _wdata["{press}"]
|
||||||
|
|
||||||
|
-- Wind speed in km/h
|
||||||
|
if _wdata["{wind mps}"] ~= "N/A" then
|
||||||
|
_wdata["{wind mps}"] = math.floor(tonumber(_wdata["{wind mps}"]) + .5)
|
||||||
|
_wdata["{wind kmh}"] = math.ceil(_wdata["{wind mps}"] * 3.6)
|
||||||
|
end -- Temperature in °C
|
||||||
|
if _wdata["{temp c}"] ~= "N/A" then
|
||||||
|
_wdata["{temp c}"] = math.floor(tonumber(_wdata["{temp c}"]) + .5)
|
||||||
|
end -- Calculate wind direction
|
||||||
|
if _wdata["{wind deg}"] ~= "N/A" then
|
||||||
|
_wdata["{wind deg}"] = tonumber(_wdata["{wind deg}"])
|
||||||
|
|
||||||
|
-- Lua tables start at [1]
|
||||||
|
if (_wdata["{wind deg}"] / 45)%1 == 0 then
|
||||||
|
_wdata["{wind aim}"] = _wdirs[_wdata["{wind deg}"] / 45 + 1]
|
||||||
|
else
|
||||||
|
_wdata["{wind aim}"] =
|
||||||
|
_wdirs[math.ceil(_wdata["{wind deg}"] / 45) + 1]..
|
||||||
|
_wdirs[math.floor(_wdata["{wind deg}"] / 45) + 1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return _wdata
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(openweather, { __call = function(_, ...) return worker(...) end })
|
35
init.lua
35
init.lua
|
@ -115,18 +115,21 @@ local function regregister(reg)
|
||||||
|
|
||||||
-- Start the timer
|
-- Start the timer
|
||||||
if reg.timer > 0 then
|
if reg.timer > 0 then
|
||||||
timers[reg.update] = {
|
local tm = timers[reg.timer] and timers[reg.timer].timer
|
||||||
timer = capi.timer({ timeout = reg.timer })
|
tm = tm or capi.timer({ timeout = reg.timer })
|
||||||
}
|
|
||||||
|
|
||||||
local tm = timers[reg.update].timer
|
|
||||||
if tm.connect_signal then
|
if tm.connect_signal then
|
||||||
tm:connect_signal("timeout", reg.update)
|
tm:connect_signal("timeout", reg.update)
|
||||||
else
|
else
|
||||||
tm:add_signal("timeout", reg.update)
|
tm:add_signal("timeout", reg.update)
|
||||||
end
|
end
|
||||||
tm:start()
|
if not timers[reg.timer] then
|
||||||
|
timers[reg.timer] = { timer = tm, refs = 1 }
|
||||||
|
else
|
||||||
|
timers[reg.timer].refs = timers[reg.timer].refs + 1
|
||||||
|
end
|
||||||
|
if not tm.started then
|
||||||
|
tm:start()
|
||||||
|
end
|
||||||
-- Initial update
|
-- Initial update
|
||||||
tm:emit_signal("timeout")
|
tm:emit_signal("timeout")
|
||||||
end
|
end
|
||||||
|
@ -194,11 +197,23 @@ function vicious.unregister(widget, keep, reg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Stop the timer
|
if not reg.running then
|
||||||
if timers[reg.update].timer.started then
|
return reg
|
||||||
timers[reg.update].timer:stop()
|
end
|
||||||
|
|
||||||
|
-- Disconnect from timer
|
||||||
|
local tm = timers[reg.timer]
|
||||||
|
if tm.timer.disconnect_signal then
|
||||||
|
tm.timer:disconnect_signal("timeout", reg.update)
|
||||||
|
else
|
||||||
|
tm.timer:remove_signal("timeout", reg.update)
|
||||||
end
|
end
|
||||||
reg.running = false
|
reg.running = false
|
||||||
|
-- Stop the timer
|
||||||
|
tm.refs = tm.refs - 1
|
||||||
|
if tm.refs == 0 and tm.timer.started then
|
||||||
|
tm.timer:stop()
|
||||||
|
end
|
||||||
|
|
||||||
return reg
|
return reg
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,4 +55,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mbox, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(mboxc, { __call = function(_, ...) return worker(...) end })
|
||||||
|
|
|
@ -23,6 +23,7 @@ local function worker(format, warg)
|
||||||
local updates = 0
|
local updates = 0
|
||||||
local manager = {
|
local manager = {
|
||||||
["Arch"] = { cmd = "pacman -Qu" },
|
["Arch"] = { cmd = "pacman -Qu" },
|
||||||
|
["Arch C"] = { cmd = "checkupdates" },
|
||||||
["Arch S"] = { cmd = "yes | pacman -Sup", sub = 1 },
|
["Arch S"] = { cmd = "yes | pacman -Sup", sub = 1 },
|
||||||
["Debian"] = { cmd = "apt-show-versions -u -b" },
|
["Debian"] = { cmd = "apt-show-versions -u -b" },
|
||||||
["Ubuntu"] = { cmd = "aptitude search '~U'" },
|
["Ubuntu"] = { cmd = "aptitude search '~U'" },
|
||||||
|
|
Loading…
Reference in New Issue