2009-11-04 23:39:38 +01:00
|
|
|
---------------------------------------------------
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
-- Vicious widgets for the awesome window manager
|
2009-11-04 23:39:38 +01:00
|
|
|
---------------------------------------------------
|
2009-09-29 22:33:19 +02:00
|
|
|
-- Licensed under the GNU General Public License v2
|
2010-01-02 21:21:54 +01:00
|
|
|
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
|
|
|
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
|
2009-11-04 23:39:38 +01:00
|
|
|
---------------------------------------------------
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
|
2010-03-14 01:55:33 +01:00
|
|
|
-- {{{ Setup environment
|
2009-10-04 00:21:15 +02:00
|
|
|
local type = type
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
local pairs = pairs
|
|
|
|
local tonumber = tonumber
|
2014-12-12 12:29:51 +01:00
|
|
|
local timer = (type(timer) == 'table' and timer or require("gears.timer"))
|
2009-10-04 00:21:15 +02:00
|
|
|
local os = { time = os.time }
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
local table = {
|
2009-10-04 00:21:15 +02:00
|
|
|
insert = table.insert,
|
|
|
|
remove = table.remove
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
}
|
2012-06-15 17:34:25 +02:00
|
|
|
local helpers = require("vicious.helpers")
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
|
2012-06-15 17:34:25 +02:00
|
|
|
-- Vicious: widgets for the awesome window manager
|
|
|
|
local vicious = {}
|
|
|
|
vicious.widgets = require("vicious.widgets")
|
2012-06-25 00:15:51 +02:00
|
|
|
--vicious.contrib = require("vicious.contrib")
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
|
2010-03-14 01:55:33 +01:00
|
|
|
-- Initialize tables
|
2009-08-26 03:27:18 +02:00
|
|
|
local timers = {}
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
local registered = {}
|
|
|
|
local widget_cache = {}
|
|
|
|
-- }}}
|
|
|
|
|
2010-03-07 03:09:44 +01:00
|
|
|
|
2010-03-07 02:39:26 +01:00
|
|
|
-- {{{ Local functions
|
|
|
|
-- {{{ Update a widget
|
|
|
|
local function update(widget, reg, disablecache)
|
|
|
|
-- Check if there are any equal widgets
|
|
|
|
if reg == nil then
|
|
|
|
for w, i in pairs(registered) do
|
|
|
|
if w == widget then
|
|
|
|
for _, r in pairs(i) do
|
|
|
|
update(w, r, disablecache)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
|
2010-03-07 02:39:26 +01:00
|
|
|
return
|
|
|
|
end
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
|
2010-03-07 02:39:26 +01:00
|
|
|
local t = os.time()
|
|
|
|
local data = {}
|
|
|
|
|
2017-07-13 22:42:26 +02:00
|
|
|
local function format_data(data)
|
|
|
|
local ret
|
|
|
|
if type(data) == "table" then
|
|
|
|
if type(reg.format) == "string" then
|
|
|
|
ret = helpers.format(reg.format, data)
|
|
|
|
elseif type(reg.format) == "function" then
|
|
|
|
ret = reg.format(widget, data)
|
|
|
|
end
|
2010-03-07 02:39:26 +01:00
|
|
|
end
|
2017-07-13 22:42:26 +02:00
|
|
|
return ret or data
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
end
|
|
|
|
|
2017-07-13 22:42:26 +02:00
|
|
|
local function update_value(data, t, cache)
|
|
|
|
if widget.add_value ~= nil then
|
|
|
|
widget:add_value(tonumber(data) and tonumber(data)/100)
|
|
|
|
elseif widget.set_value ~= nil then
|
|
|
|
widget:set_value(tonumber(data) and tonumber(data)/100)
|
|
|
|
elseif widget.set_markup ~= nil then
|
|
|
|
widget:set_markup(data)
|
|
|
|
else
|
|
|
|
widget.text = data
|
|
|
|
end
|
|
|
|
-- Update cache
|
|
|
|
if t and cache then
|
|
|
|
cache.time, cache.data = t, data
|
2010-03-07 02:39:26 +01:00
|
|
|
end
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
end
|
2017-10-23 16:24:17 +02:00
|
|
|
|
2017-07-13 22:42:26 +02:00
|
|
|
-- Check for cached output newer than the last update
|
|
|
|
local c = widget_cache[reg.wtype]
|
|
|
|
return update_value(format_data(c.data))
|
2018-01-20 04:33:49 +01:00
|
|
|
if c and t < c.time + reg.timer and not disablecache then
|
2017-07-13 22:42:26 +02:00
|
|
|
elseif reg.wtype then
|
2017-11-28 19:18:59 +01:00
|
|
|
if type(reg.wtype) == "table" and reg.wtype.async then
|
2017-07-13 22:42:26 +02:00
|
|
|
if not reg.lock then
|
|
|
|
reg.lock = true
|
2017-10-23 16:24:17 +02:00
|
|
|
return reg.wtype.async(reg.format,
|
|
|
|
reg.warg,
|
2017-07-13 22:42:26 +02:00
|
|
|
function(data)
|
|
|
|
update_value(format_data(data), t, c)
|
|
|
|
reg.lock=false
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
else
|
2017-10-23 16:24:17 +02:00
|
|
|
return update_value(format_data(reg.wtype(reg.format, reg.warg)), t, c)
|
2017-07-13 22:42:26 +02:00
|
|
|
end
|
2010-03-07 02:39:26 +01:00
|
|
|
end
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- {{{ Register from reg object
|
2010-03-07 02:39:26 +01:00
|
|
|
local function regregister(reg)
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
if not reg.running then
|
|
|
|
if registered[reg.widget] == nil then
|
|
|
|
registered[reg.widget] = {}
|
|
|
|
table.insert(registered[reg.widget], reg)
|
|
|
|
else
|
2009-09-14 17:25:23 +02:00
|
|
|
local already = false
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
|
|
|
|
for w, i in pairs(registered) do
|
|
|
|
if w == reg.widget then
|
2009-08-08 17:42:28 +02:00
|
|
|
for _, v in pairs(i) do
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
if v == reg then
|
|
|
|
already = true
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if already then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if not already then
|
|
|
|
table.insert(registered[reg.widget], reg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-09-14 17:25:23 +02:00
|
|
|
-- Start the timer
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
if reg.timer > 0 then
|
2013-11-07 05:11:49 +01:00
|
|
|
local tm = timers[reg.timer] and timers[reg.timer].timer
|
2014-12-12 12:29:51 +01:00
|
|
|
tm = tm or timer({ timeout = reg.timer })
|
2010-09-14 15:21:16 +02:00
|
|
|
if tm.connect_signal then
|
|
|
|
tm:connect_signal("timeout", reg.update)
|
|
|
|
else
|
|
|
|
tm:add_signal("timeout", reg.update)
|
|
|
|
end
|
2013-11-07 05:11:49 +01:00
|
|
|
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
|
2010-10-09 10:03:21 +02:00
|
|
|
-- Initial update
|
2013-12-15 18:20:50 +01:00
|
|
|
reg.update()
|
2010-10-09 10:03:21 +02:00
|
|
|
end
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
reg.running = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- }}}
|
2010-03-07 02:39:26 +01:00
|
|
|
-- }}}
|
|
|
|
|
2010-03-07 03:09:44 +01:00
|
|
|
|
2010-03-14 01:55:33 +01:00
|
|
|
-- {{{ Global functions
|
2010-03-07 02:39:26 +01:00
|
|
|
-- {{{ Register a widget
|
2012-06-15 17:34:25 +02:00
|
|
|
function vicious.register(widget, wtype, format, timer, warg)
|
2010-03-07 02:39:26 +01:00
|
|
|
local widget = widget
|
2011-08-18 19:43:09 +02:00
|
|
|
local reg = {
|
2011-08-18 20:44:04 +02:00
|
|
|
-- Set properties
|
|
|
|
wtype = wtype,
|
2017-07-13 22:42:26 +02:00
|
|
|
lock = false,
|
2011-08-18 20:44:04 +02:00
|
|
|
format = format,
|
|
|
|
timer = timer,
|
|
|
|
warg = warg,
|
|
|
|
widget = widget,
|
2011-08-18 19:43:09 +02:00
|
|
|
}
|
2013-12-15 18:34:55 +01:00
|
|
|
-- Set functions
|
|
|
|
reg.update = function ()
|
|
|
|
update(widget, reg)
|
|
|
|
end
|
2010-03-07 02:39:26 +01:00
|
|
|
|
|
|
|
-- Default to 2s timer
|
|
|
|
if reg.timer == nil then
|
|
|
|
reg.timer = 2
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Register a reg object
|
|
|
|
regregister(reg)
|
|
|
|
|
|
|
|
-- Return a reg object for reuse
|
|
|
|
return reg
|
|
|
|
end
|
|
|
|
-- }}}
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
|
2009-09-14 17:25:23 +02:00
|
|
|
-- {{{ Unregister a widget
|
2012-06-15 17:34:25 +02:00
|
|
|
function vicious.unregister(widget, keep, reg)
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
if reg == nil then
|
|
|
|
for w, i in pairs(registered) do
|
|
|
|
if w == widget then
|
2009-08-08 17:42:28 +02:00
|
|
|
for _, v in pairs(i) do
|
2012-06-15 17:34:25 +02:00
|
|
|
reg = vicious.unregister(w, keep, v)
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return reg
|
|
|
|
end
|
|
|
|
|
|
|
|
if not keep then
|
|
|
|
for w, i in pairs(registered) do
|
|
|
|
if w == widget then
|
|
|
|
for k, v in pairs(i) do
|
|
|
|
if v == reg then
|
|
|
|
table.remove(registered[w], k)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-07 05:11:49 +01:00
|
|
|
if not reg.running then
|
|
|
|
return reg
|
|
|
|
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)
|
2009-08-26 03:27:18 +02:00
|
|
|
end
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
reg.running = false
|
2013-11-07 05:11:49 +01:00
|
|
|
-- Stop the timer
|
|
|
|
tm.refs = tm.refs - 1
|
|
|
|
if tm.refs == 0 and tm.timer.started then
|
|
|
|
tm.timer:stop()
|
|
|
|
end
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
|
|
|
|
return reg
|
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
2010-03-07 02:39:26 +01:00
|
|
|
-- {{{ Enable caching of a widget type
|
2012-06-15 17:34:25 +02:00
|
|
|
function vicious.cache(wtype)
|
2010-03-13 21:51:40 +01:00
|
|
|
if wtype ~= nil then
|
|
|
|
if widget_cache[wtype] == nil then
|
2018-01-20 04:33:49 +01:00
|
|
|
widget_cache[wtype] = { data = nil, time = 0 }
|
2010-03-13 21:51:40 +01:00
|
|
|
end
|
2010-03-07 02:39:26 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
2010-03-07 03:09:44 +01:00
|
|
|
-- {{{ Force update of widgets
|
2012-06-15 17:34:25 +02:00
|
|
|
function vicious.force(wtable)
|
2010-03-13 22:46:45 +01:00
|
|
|
if type(wtable) == "table" then
|
|
|
|
for _, w in pairs(wtable) do
|
2010-03-07 03:09:44 +01:00
|
|
|
update(w, nil, true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
2010-03-07 02:39:26 +01:00
|
|
|
-- {{{ Suspend all widgets
|
2012-06-15 17:34:25 +02:00
|
|
|
function vicious.suspend()
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
for w, i in pairs(registered) do
|
2009-08-08 17:42:28 +02:00
|
|
|
for _, v in pairs(i) do
|
2012-06-15 17:34:25 +02:00
|
|
|
vicious.unregister(w, true, v)
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
2010-03-07 02:39:26 +01:00
|
|
|
-- {{{ Activate a widget
|
2012-06-15 17:34:25 +02:00
|
|
|
function vicious.activate(widget)
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
for w, i in pairs(registered) do
|
|
|
|
if widget == nil or w == widget then
|
2009-08-08 17:42:28 +02:00
|
|
|
for _, v in pairs(i) do
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
regregister(v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- }}}
|
2012-06-15 17:34:25 +02:00
|
|
|
|
2017-02-23 22:48:39 +01:00
|
|
|
-- {{{ Get custom widget format data
|
2017-02-27 10:00:59 +01:00
|
|
|
function vicious.call(myw, format, warg)
|
|
|
|
local mydata = myw(format, warg)
|
|
|
|
if type(format) == "string" then
|
|
|
|
return helpers.format(format, mydata)
|
|
|
|
elseif type(format) == "function" then
|
|
|
|
return format(myw, mydata)
|
|
|
|
end
|
2017-02-23 22:48:39 +01:00
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
2012-06-15 17:34:25 +02:00
|
|
|
return vicious
|
|
|
|
|
Import of vicious source tree.
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
2009-07-29 17:59:32 +02:00
|
|
|
-- }}}
|