--]]
-local helpers = require("lain.helpers")
-local shell = require("awful.util").shell
-local wibox = require("wibox")
-local string = { match = string.match,
- format = string.format }
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local shell = require("awful.util").shell
+local wibox = require("wibox")
+local string = { match = string.match,
+ format = string.format }
-- ALSA volume
-- lain.widget.alsa
-local function worker(args)
+local function factory(args)
local alsa = { widget = wibox.widget.textbox() }
local args = args or {}
local timeout = args.timeout or 5
return alsa
end
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
_muted = false
}
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 5
local settings = args.settings or function() end
return alsabar
end
-return setmetatable(alsabar, { __call = function(_, ...) return worker(...) end })
+return setmetatable(alsabar, { __call = function(_, ...) return factory(...) end })
--]]
-local first_line = require("lain.helpers").first_line
-local newtimer = require("lain.helpers").newtimer
-local naughty = require("naughty")
-local wibox = require("wibox")
-local math = { abs = math.abs,
- floor = math.floor,
- log10 = math.log10,
- min = math.min }
-local string = { format = string.format }
-local ipairs = ipairs
-local type = type
-local tonumber = tonumber
-local setmetatable = setmetatable
+local first_line = require("lain.helpers").first_line
+local newtimer = require("lain.helpers").newtimer
+local naughty = require("naughty")
+local wibox = require("wibox")
+local math = { abs = math.abs,
+ floor = math.floor,
+ log10 = math.log10,
+ min = math.min }
+local string = { format = string.format }
+local ipairs = ipairs
+local type = type
+local tonumber = tonumber
-- Battery infos
-- lain.widget.bat
-local function worker(args)
+local function factory(args)
local bat = { widget = wibox.widget.textbox() }
local args = args or {}
local timeout = args.timeout or 30
return bat
end
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
awful.button({ }, 5, function () calendar.show(0, 1) end)))
end
-local function worker(args)
+local function factory(args)
local args = args or {}
calendar.cal = args.cal or "/usr/bin/cal"
calendar.attach_to = args.attach_to or {}
for i, widget in ipairs(calendar.attach_to) do calendar.attach(widget) end
end
-return setmetatable(calendar, { __call = function(_, ...) return worker(...) end })
+return setmetatable(calendar, { __call = function(_, ...) return factory(...) end })
-- lain.widget.contrib.gpmdp
local gpmdp = {}
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 2
local notify = args.notify or "off"
return gpmdp
end
-return setmetatable(gpmdp, { __call = function(_, ...) return worker(...) end })
+return setmetatable(gpmdp, { __call = function(_, ...) return factory(...) end })
local wrequire = require("lain.helpers").wrequire
local setmetatable = setmetatable
-local widgets = { _NAME = "lain.widget.contrib" }
+local widget = { _NAME = "lain.widget.contrib" }
-return setmetatable(widgets, { __index = wrequire })
+return setmetatable(widget, { __index = wrequire })
-- Keyboard layout switcher
-- lain.widget.contrib.kblayout
-local kbdlayout = {}
-
-local function worker(args)
- local args = args or {}
- local layouts = args.layouts or {}
- local settings = args.settings or function () end
- local add_us_secondary = true
- local timeout = args.timeout or 5
- local idx = 1
-
- if args.add_us_secondary == false then add_us_secondary = false end
-
- kbdlayout.widget = wibox.widget.textbox()
-
- local function kbd_run_settings(layout, variant)
- kbdlayout_now = {
- layout = string.match(layout, "[^,]+"), -- Make sure to match the primary layout only.
- variant = variant
- }
- widget = kbdlayout.widget
- settings()
- end
-
- function kbdlayout.update()
- helpers.async("setxkbmap -query", function(status)
- kbd_run_settings(string.match(status, "layout:%s*([^\n]*)"),
- string.match(status, "variant:%s*([^\n]*)"))
- end)
- end
-
- function kbdlayout.set(i)
- if #layouts == 0 then return end
- idx = ((i - 1) % #layouts) + 1 -- Make sure to wrap around as needed.
- local to_execute = "setxkbmap " .. layouts[idx].layout
-
- if add_us_secondary and not string.match(layouts[idx].layout, ",?us,?") then
- to_execute = to_execute .. ",us"
- end
-
- if layouts[idx].variant then
- to_execute = to_execute .. " " .. layouts[idx].variant
- end
- if execute(to_execute) then
- kbd_run_settings(layouts[idx].layout, layouts[idx].variant)
- end
+local function factory(args)
+ local kbdlayout = { widget = wibox.widget.textbox() }
+ local args = args or {}
+ local layouts = args.layouts or {}
+ local settings = args.settings or function () end
+ local add_us_secondary = true
+ local timeout = args.timeout or 5
+ local idx = 1
+
+ if args.add_us_secondary == false then add_us_secondary = false end
+
+ local function kbd_run_settings(layout, variant)
+ kbdlayout_now = {
+ layout = string.match(layout, "[^,]+"), -- Make sure to match the primary layout only.
+ variant = variant
+ }
+ widget = kbdlayout.widget
+ settings()
+ end
+
+ function kbdlayout.update()
+ helpers.async("setxkbmap -query", function(status)
+ kbd_run_settings(string.match(status, "layout:%s*([^\n]*)"),
+ string.match(status, "variant:%s*([^\n]*)"))
+ end)
+ end
+
+ function kbdlayout.set(i)
+ if #layouts == 0 then return end
+ idx = ((i - 1) % #layouts) + 1 -- Make sure to wrap around as needed.
+ local to_execute = "setxkbmap " .. layouts[idx].layout
+
+ if add_us_secondary and not string.match(layouts[idx].layout, ",?us,?") then
+ to_execute = to_execute .. ",us"
+ end
+
+ if layouts[idx].variant then
+ to_execute = to_execute .. " " .. layouts[idx].variant
+ end
+
+ if execute(to_execute) then
+ kbd_run_settings(layouts[idx].layout, layouts[idx].variant)
+ end
end
function kbdlayout.next() kbdlayout.set(idx + 1) end
return kbdlayout
end
-return setmetatable({}, { __call = function (_, ...) return worker(...) end })
+return factory
-- lain.widget.contrib.moc
local moc = {}
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 2
local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
return moc
end
-return setmetatable(moc, { __call = function(_, ...) return worker(...) end })
+return setmetatable(moc, { __call = function(_, ...) return factory(...) end })
-- lain.widget.cpu
local cpu = { core = {} }
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 2
local settings = args.settings or function() end
return cpu
end
-return setmetatable(cpu, { __call = function(_, ...) return worker(...) end })
+return setmetatable(cpu, { __call = function(_, ...) return factory(...) end })
--]]
local helpers = require("lain.helpers")
-
local shell = require("awful.util").shell
local focused = require("awful.screen").focused
local wibox = require("wibox")
local naughty = require("naughty")
-
local string = string
local tonumber = tonumber
-
local setmetatable = setmetatable
-- File system disk space usage
})
end
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 600
local partition = args.partition or "/"
return fs
end
-return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
+return setmetatable(fs, { __call = function(_, ...) return factory(...) end })
--]]
-local helpers = require("lain.helpers")
-local naughty = require("naughty")
-local wibox = require("wibox")
-local string = { format = string.format,
- gsub = string.gsub }
-local type = type
-local tonumber = tonumber
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local naughty = require("naughty")
+local wibox = require("wibox")
+local string = { format = string.format,
+ gsub = string.gsub }
+local type = type
+local tonumber = tonumber
-- Mail IMAP check
-- lain.widget.imap
-local function worker(args)
+local function factory(args)
local imap = { widget = wibox.widget.textbox() }
local args = args or {}
local server = args.server
return imap
end
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
local wrequire = require("lain.helpers").wrequire
local setmetatable = setmetatable
-local widgets = { _NAME = "lain.widget" }
+local widget = { _NAME = "lain.widget" }
-return setmetatable(widgets, { __index = wrequire })
+return setmetatable(widget, { __index = wrequire })
-- lain.widget.mem
local mem = {}
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 2
local settings = args.settings or function() end
return mem
end
-return setmetatable(mem, { __call = function(_, ...) return worker(...) end })
+return setmetatable(mem, { __call = function(_, ...) return factory(...) end })
-- lain.widget.mpd
local mpd = {}
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 2
local password = (args.password and #args.password > 0 and string.format("password %s\\n", args.password)) or ""
return mpd
end
-return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })
+return setmetatable(mpd, { __call = function(_, ...) return factory(...) end })
--]]
-local helpers = require("lain.helpers")
-local naughty = require("naughty")
-local wibox = require("wibox")
-local string = { format = string.format,
- match = string.match }
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local naughty = require("naughty")
+local wibox = require("wibox")
+local string = { format = string.format,
+ match = string.match }
-- Network infos
-- lain.widget.net
-local function worker(args)
+local function factory(args)
local net = { widget = wibox.widget.textbox() }
net.last_t = 0
net.last_r = 0
return net
end
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
--]]
-local helpers = require("lain.helpers")
-local shell = require("awful.util").shell
-local wibox = require("wibox")
-local string = { gmatch = string.gmatch,
- match = string.match,
- format = string.format }
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local shell = require("awful.util").shell
+local wibox = require("wibox")
+local string = { gmatch = string.gmatch,
+ match = string.match,
+ format = string.format }
-- PulseAudio volume
-- lain.widget.pulseaudio
-local function worker(args)
+local function factory(args)
local pulseaudio = { widget = wibox.widget.textbox() }
local args = args or {}
local devicetype = args.devicetype or "sink"
return pulseaudio
end
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
_muted = false
}
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 5
local settings = args.settings or function() end
return pulsebar
end
-return setmetatable(pulsebar, { __call = function(_, ...) return worker(...) end })
+return setmetatable(pulsebar, { __call = function(_, ...) return factory(...) end })
-- lain.widget.sysload
local sysload = {}
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 2
local settings = args.settings or function() end
return sysload
end
-return setmetatable(sysload, { __call = function(_, ...) return worker(...) end })
+return setmetatable(sysload, { __call = function(_, ...) return factory(...) end })
-- lain.widget.temp
local temp = {}
-local function worker(args)
+local function factory(args)
local args = args or {}
local timeout = args.timeout or 2
local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
return temp
end
-return setmetatable(temp, { __call = function(_, ...) return worker(...) end })
+return setmetatable(temp, { __call = function(_, ...) return factory(...) end })
--]]
-local helpers = require("lain.helpers")
-local textbox = require("wibox.widget.textbox")
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local textbox = require("wibox.widget.textbox")
-- Template for asynchronous watcher widgets
-- lain.widget.watch
-local function worker(args)
- local watch = {}
+local function factory(args)
+ local watch = { widget = args.widget or textbox() }
local args = args or {}
local timeout = args.timeout or 5
local nostart = args.nostart or false
local cmd = args.cmd
local settings = args.settings or function() widget:set_text(output) end
- watch.widget = args.widget or textbox()
-
function watch.update()
helpers.async(cmd, function(f)
output = f
return watch
end
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
--]]
-local helpers = require("lain.helpers")
-local json = require("lain.util").dkjson
-local focused = require("awful.screen").focused
-local naughty = require("naughty")
-local wibox = require("wibox")
-local math = { floor = math.floor }
-local os = { time = os.time,
- date = os.date,
- difftime = os.difftime }
-local string = { format = string.format,
- gsub = string.gsub }
-local tonumber = tonumber
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local json = require("lain.util").dkjson
+local focused = require("awful.screen").focused
+local naughty = require("naughty")
+local wibox = require("wibox")
+local math = { floor = math.floor }
+local os = { time = os.time,
+ date = os.date,
+ difftime = os.difftime }
+local string = { format = string.format,
+ gsub = string.gsub }
+local tonumber = tonumber
-- OpenWeatherMap
-- current weather and X-days forecast
-- lain.widget.weather
-local function worker(args)
+local function factory(args)
local weather = { widget = wibox.widget.textbox() }
local args = args or {}
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default
return weather
end
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory