mirror of https://github.com/lcpz/lain.git
fix #288
This commit is contained in:
parent
8c2e1df0c3
commit
ddbf283f0e
|
@ -35,7 +35,7 @@ local function worker(args)
|
|||
|
||||
abase.timer = helpers.newtimer(cmd, timeout, abase.update, nostart, stoppable)
|
||||
|
||||
return setmetatable(abase, { __index = abase.widget })
|
||||
return abase
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -50,7 +50,7 @@ local function worker(args)
|
|||
|
||||
helpers.newtimer(string.format("alsa-%s-%s", alsa.cmd, alsa.channel), timeout, alsa.update)
|
||||
|
||||
return setmetatable(alsa, { __index = alsa.widget })
|
||||
return alsa
|
||||
end
|
||||
|
||||
return setmetatable(alsa, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -22,8 +22,6 @@ local function worker(args)
|
|||
local cmd = args.cmd or ""
|
||||
local settings = args.settings or function() end
|
||||
|
||||
base.widget = wibox.widget.textbox()
|
||||
|
||||
function base.update()
|
||||
output = helpers.read_pipe(cmd)
|
||||
if output ~= base.prev then
|
||||
|
@ -35,7 +33,7 @@ local function worker(args)
|
|||
|
||||
base.timer = helpers.newtimer(cmd, timeout, base.update, nostart, stoppable)
|
||||
|
||||
return setmetatable(base, { __index = base.widget })
|
||||
return base
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -177,7 +177,7 @@ local function worker(args)
|
|||
|
||||
newtimer("batteries", timeout, bat.update)
|
||||
|
||||
return setmetatable(bat, { __index = bat.widget })
|
||||
return bat
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -19,7 +19,7 @@ local setmetatable = setmetatable
|
|||
|
||||
-- Google Play Music Desktop infos
|
||||
-- lain.widget.contrib.gpmdp
|
||||
local gpmdp = {}
|
||||
local gpmdp = helpers.make_widget_textbox()
|
||||
|
||||
local function worker(args)
|
||||
local args = args or {}
|
||||
|
@ -30,8 +30,6 @@ local function worker(args)
|
|||
os.getenv("HOME") .. "/.config/Google Play Music Desktop Player/json_store/playback.json"
|
||||
local settings = args.settings or function() end
|
||||
|
||||
gpmdp.widget = wibox.widget.textbox('')
|
||||
|
||||
gpmdp_notification_preset = {
|
||||
title = "Now playing",
|
||||
timeout = 6
|
||||
|
@ -86,7 +84,7 @@ local function worker(args)
|
|||
|
||||
gpmdp.timer = helpers.newtimer("gpmdp", timeout, gpmdp.update, true, true)
|
||||
|
||||
return setmetatable(gpmdp, { __index = gpmdp.widget })
|
||||
return gpmdp
|
||||
end
|
||||
|
||||
return setmetatable(gpmdp, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -72,7 +72,7 @@ local function worker(args)
|
|||
|
||||
helpers.newtimer("kbdlayout", timeout, kbdlayout.update)
|
||||
|
||||
return setmetatable(kbdlayout, { __index = kbdlayout.widget })
|
||||
return kbdlayout
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function (_, ...) return worker(...) end })
|
||||
|
|
|
@ -93,7 +93,7 @@ local function worker(args)
|
|||
|
||||
moc.timer = helpers.newtimer("moc", timeout, moc.update, true, true)
|
||||
|
||||
return setmetatable(moc, { __index = moc.widget })
|
||||
return moc
|
||||
end
|
||||
|
||||
return setmetatable(moc, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -19,19 +19,16 @@ local newtimer = require("lain.helpers").newtimer
|
|||
local first_line = require("lain.helpers").first_line
|
||||
local naughty = require("naughty")
|
||||
local wibox = require("wibox")
|
||||
|
||||
local string = { format = string.format }
|
||||
local math = { floor = math.floor }
|
||||
local tostring = tostring
|
||||
local setmetatable = setmetatable
|
||||
|
||||
package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .. "?.lua;" .. package.path
|
||||
local smapi = require("smapi")
|
||||
|
||||
-- ThinkPad SMAPI-enabled battery info widget
|
||||
-- lain.widgets.contrib.tpbat
|
||||
local tpbat = { }
|
||||
local tpbat_notification = nil
|
||||
|
||||
function tpbat.hide()
|
||||
if not tpbat.notification then return end
|
||||
|
@ -69,7 +66,7 @@ function tpbat.show(t_out)
|
|||
local str = string.format("%s : %s %s (%s)\n", bat.name, mfgr, model, chem)
|
||||
.. string.format("\n%s \t\t\t %s", status:upper(), msg)
|
||||
|
||||
tpbat_notification = naughty.notify({
|
||||
tpbat.notification = naughty.notify({
|
||||
preset = naughty.config.defaults,
|
||||
text = str,
|
||||
timeout = t_out,
|
||||
|
@ -86,7 +83,7 @@ function tpbat.register(args)
|
|||
tpbat.bat = smapi:battery(battery) -- Create a new battery
|
||||
local bat = tpbat.bat
|
||||
|
||||
tpbat.widget = wibox.widget.textbox('')
|
||||
tpbat.widget = wibox.widget.textbox()
|
||||
|
||||
bat_notification_low_preset = {
|
||||
title = "Battery low",
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
|
||||
--]]
|
||||
|
||||
local lines_match = require("lain.helpers").lines_match
|
||||
local newtimer = require("lain.helpers").newtimer
|
||||
local helpers = require("lain.helpers")
|
||||
local wibox = require("wibox")
|
||||
local math = { ceil = math.ceil }
|
||||
local string = { format = string.format,
|
||||
|
@ -18,20 +17,20 @@ local setmetatable = setmetatable
|
|||
|
||||
-- CPU usage
|
||||
-- lain.widgets.cpu
|
||||
local cpu = { core = {} }
|
||||
local cpu = helpers.make_widget_textbox()
|
||||
|
||||
local function worker(args)
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 2
|
||||
local settings = args.settings or function() end
|
||||
|
||||
cpu.widget = wibox.widget.textbox()
|
||||
cpu.core = {}
|
||||
|
||||
function update()
|
||||
-- Read the amount of time the CPUs have spent performing
|
||||
-- different kinds of work. Read the first line of /proc/stat
|
||||
-- which is the sum of all CPUs.
|
||||
local times = lines_match("cpu","/proc/stat")
|
||||
local times = helpers.lines_match("cpu","/proc/stat")
|
||||
|
||||
for index,time in pairs(times) do
|
||||
local coreid = index - 1
|
||||
|
@ -75,9 +74,9 @@ local function worker(args)
|
|||
settings()
|
||||
end
|
||||
|
||||
newtimer("cpu", timeout, update)
|
||||
helpers.newtimer("cpu", timeout, update)
|
||||
|
||||
return setmetatable(cpu, { __index = cpu.widget })
|
||||
return cpu
|
||||
end
|
||||
|
||||
return setmetatable(cpu, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -124,7 +124,7 @@ local function worker(args)
|
|||
|
||||
helpers.newtimer(partition, timeout, fs.update)
|
||||
|
||||
return setmetatable(fs, { __index = fs.widget })
|
||||
return fs
|
||||
end
|
||||
|
||||
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -17,7 +17,7 @@ local setmetatable = setmetatable
|
|||
-- Mail IMAP check
|
||||
-- lain.widgets.imap
|
||||
|
||||
local function worker(args )
|
||||
local function worker(args)
|
||||
local imap = helpers.make_widget_textbox()
|
||||
local args = args or {}
|
||||
local server = args.server
|
||||
|
@ -76,7 +76,7 @@ local function worker(args )
|
|||
|
||||
imap.timer = helpers.newtimer(mail, timeout, update, true, true)
|
||||
|
||||
return setmetatable(imap, { __index = imap.widget })
|
||||
return imap
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -18,7 +18,7 @@ local setmetatable = setmetatable
|
|||
|
||||
-- Maildir check (synchronous)
|
||||
-- lain.widgets.maildir
|
||||
local maildir = {}
|
||||
local maildir = helpers.make_widget_textbox()
|
||||
|
||||
local function worker(args)
|
||||
local args = args or {}
|
||||
|
@ -26,12 +26,10 @@ local function worker(args)
|
|||
local mailpath = args.mailpath or os.getenv("HOME") .. "/Mail"
|
||||
local ignore_boxes = args.ignore_boxes or {}
|
||||
local settings = args.settings or function() end
|
||||
local ext_mail_cmd = args.external_mail_cmd
|
||||
|
||||
maildir.widget = wibox.widget.textbox()
|
||||
local cmd = args.cmd
|
||||
|
||||
function maildir.update()
|
||||
if ext_mail_cmd then awful.spawn(ext_mail_cmd) end
|
||||
if cmd then helpers.async({ awful.util.shell, "-c", cmd }, function() end) end
|
||||
|
||||
-- Find pathes to mailboxes.
|
||||
local p = io.popen(string.format("find %s -mindepth 1 -maxdepth 2 -type d -not -name .git", mailpath))
|
||||
|
@ -78,7 +76,7 @@ local function worker(args)
|
|||
|
||||
maildir.timer = helpers.newtimer(mailpath, timeout, maildir.update, true, true)
|
||||
|
||||
return setmetatable(maildir, { __index = maildir.widget })
|
||||
return maildir
|
||||
end
|
||||
|
||||
return setmetatable(maildir, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
--]]
|
||||
|
||||
local newtimer = require("lain.helpers").newtimer
|
||||
local helpers = require("lain.helpers")
|
||||
local wibox = require("wibox")
|
||||
local gmatch = string.gmatch
|
||||
local lines = io.lines
|
||||
|
@ -16,15 +16,13 @@ local setmetatable = setmetatable
|
|||
|
||||
-- Memory usage (ignoring caches)
|
||||
-- lain.widgets.mem
|
||||
local mem = {}
|
||||
local mem = helpers.make_widget_textbox()
|
||||
|
||||
local function worker(args)
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 2
|
||||
local settings = args.settings or function() end
|
||||
|
||||
mem.widget = wibox.widget.textbox()
|
||||
|
||||
function update()
|
||||
mem_now = {}
|
||||
for line in lines("/proc/meminfo") do
|
||||
|
@ -48,9 +46,9 @@ local function worker(args)
|
|||
settings()
|
||||
end
|
||||
|
||||
newtimer("mem", timeout, update)
|
||||
helpers.newtimer("mem", timeout, update)
|
||||
|
||||
return setmetatable(mem, { __index = mem.widget })
|
||||
return mem
|
||||
end
|
||||
|
||||
return setmetatable(mem, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -129,7 +129,7 @@ local function worker(args)
|
|||
|
||||
mpd.timer = helpers.newtimer("mpd", timeout, mpd.update, true, true)
|
||||
|
||||
return setmetatable(mpd, { __index = mpd.widget })
|
||||
return mpd
|
||||
end
|
||||
|
||||
return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -119,7 +119,7 @@ local function worker(args)
|
|||
|
||||
helpers.newtimer("network", timeout, update)
|
||||
|
||||
return setmetatable(net, { __index = net.widget })
|
||||
return net
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -16,7 +16,7 @@ local setmetatable = setmetatable
|
|||
|
||||
-- PulseAudio volume
|
||||
-- lain.widgets.pulseaudio
|
||||
local pulseaudio = {}
|
||||
local pulseaudio = helpers.make_widget_textbox()
|
||||
|
||||
local function worker(args)
|
||||
local args = args or {}
|
||||
|
@ -25,7 +25,6 @@ local function worker(args)
|
|||
local scallback = args.scallback
|
||||
|
||||
pulseaudio.cmd = args.cmd or "pacmd list-sinks | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'"
|
||||
pulseaudio.widget = wibox.widget.textbox()
|
||||
|
||||
function pulseaudio.update()
|
||||
if scallback then pulseaudio.cmd = scallback() end
|
||||
|
@ -54,7 +53,7 @@ local function worker(args)
|
|||
|
||||
helpers.newtimer("pulseaudio", timeout, pulseaudio.update)
|
||||
|
||||
return setmetatable(pulseaudio, { __index = pulseaudio.widget })
|
||||
return pulseaudio
|
||||
end
|
||||
|
||||
return setmetatable(pulseaudio, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
--]]
|
||||
|
||||
local newtimer = require("lain.helpers").newtimer
|
||||
local helpers = require("lain.helpers")
|
||||
local wibox = require("wibox")
|
||||
local io = { open = io.open }
|
||||
local string = { match = string.match }
|
||||
|
@ -15,15 +15,13 @@ local setmetatable = setmetatable
|
|||
|
||||
-- System load
|
||||
-- lain.widgets.sysload
|
||||
local sysload = {}
|
||||
local sysload = helpers.make_widget_textbox()
|
||||
|
||||
local function worker(args)
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 2
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 2
|
||||
local settings = args.settings or function() end
|
||||
|
||||
sysload.widget = wibox.widget.textbox()
|
||||
|
||||
function update()
|
||||
local f = io.open("/proc/loadavg")
|
||||
local ret = f:read("*all")
|
||||
|
@ -35,9 +33,9 @@ local function worker(args)
|
|||
settings()
|
||||
end
|
||||
|
||||
newtimer("sysload", timeout, update)
|
||||
helpers.newtimer("sysload", timeout, update)
|
||||
|
||||
return setmetatable(sysload, { __index = sysload.widget })
|
||||
return sysload
|
||||
end
|
||||
|
||||
return setmetatable(sysload, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
--]]
|
||||
|
||||
local newtimer = require("lain.helpers").newtimer
|
||||
local helpers = require("lain.helpers")
|
||||
local wibox = require("wibox")
|
||||
local io = { open = io.open }
|
||||
local tonumber = tonumber
|
||||
|
@ -14,7 +14,7 @@ local setmetatable = setmetatable
|
|||
|
||||
-- coretemp
|
||||
-- lain.widgets.temp
|
||||
local temp = {}
|
||||
local temp = helpers.make_widget_textbox()
|
||||
|
||||
local function worker(args)
|
||||
local args = args or {}
|
||||
|
@ -22,8 +22,6 @@ local function worker(args)
|
|||
local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
|
||||
local settings = args.settings or function() end
|
||||
|
||||
temp.widget = wibox.widget.textbox()
|
||||
|
||||
function update()
|
||||
local f = io.open(tempfile)
|
||||
if f then
|
||||
|
@ -37,9 +35,9 @@ local function worker(args)
|
|||
settings()
|
||||
end
|
||||
|
||||
newtimer("coretemp", timeout, update)
|
||||
helpers.newtimer("coretemp", timeout, update)
|
||||
|
||||
return setmetatable(temp, { __index = temp.widget })
|
||||
return temp
|
||||
end
|
||||
|
||||
return setmetatable(temp, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
|
||||
--]]
|
||||
|
||||
local async = require("lain.helpers").async
|
||||
local newtimer = require("lain.helpers").newtimer
|
||||
local lain_icons = require("lain.helpers").icons_dir
|
||||
local helpers = require("lain.helpers")
|
||||
local json = require("lain.util").dkjson
|
||||
local focused = require("awful.screen").focused
|
||||
local naughty = require("naughty")
|
||||
|
@ -27,7 +25,7 @@ local setmetatable = setmetatable
|
|||
-- lain.widgets.weather
|
||||
|
||||
local function worker(args)
|
||||
local weather = {}
|
||||
local weather = helpers.make_widget_textbox()
|
||||
local args = args or {}
|
||||
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default
|
||||
local timeout = args.timeout or 900 -- 15 min
|
||||
|
@ -44,7 +42,7 @@ local function worker(args)
|
|||
local lang = args.lang or "en"
|
||||
local cnt = args.cnt or 5
|
||||
local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'"
|
||||
local icons_path = args.icons_path or lain_icons .. "openweathermap/"
|
||||
local icons_path = args.icons_path or helpers.icons_dir .. "openweathermap/"
|
||||
local notification_preset = args.notification_preset or {}
|
||||
local notification_text_fun = args.notification_text_fun or
|
||||
function (wn)
|
||||
|
@ -58,9 +56,9 @@ local function worker(args)
|
|||
local followtag = args.followtag or false
|
||||
local settings = args.settings or function() end
|
||||
|
||||
weather.widget = wibox.widget.textbox(weather_na_markup)
|
||||
weather.widget:set_markup(weather_na_markup)
|
||||
weather.icon_path = icons_path .. "na.png"
|
||||
weather.icon = wibox.widget.imagebox(weather.icon_path)
|
||||
weather.icon = wibox.widget.imagebox(weather.icon_path)
|
||||
|
||||
function weather.show(t_out)
|
||||
weather.hide()
|
||||
|
@ -99,7 +97,7 @@ local function worker(args)
|
|||
|
||||
function weather.forecast_update()
|
||||
local cmd = string.format(forecast_call, city_id, units, lang, cnt, APPID)
|
||||
async(cmd, function(f)
|
||||
helpers.async(cmd, function(f)
|
||||
local pos, err
|
||||
weather_now, pos, err = json.decode(f, 1, nil)
|
||||
|
||||
|
@ -119,7 +117,7 @@ local function worker(args)
|
|||
|
||||
function weather.update()
|
||||
local cmd = string.format(current_call, city_id, units, lang, APPID)
|
||||
async(cmd, function(f)
|
||||
helpers.async(cmd, function(f)
|
||||
local pos, err, icon
|
||||
weather_now, pos, err = json.decode(f, 1, nil)
|
||||
|
||||
|
@ -160,10 +158,10 @@ local function worker(args)
|
|||
|
||||
weather.attach(weather.widget)
|
||||
|
||||
weather.timer = newtimer("weather-" .. city_id, timeout, weather.update, false, true)
|
||||
weather.timer_forecast = newtimer("weather_forecast-" .. city_id, timeout, weather.forecast_update, false, true)
|
||||
weather.timer = helpers.newtimer("weather-" .. city_id, timeout, weather.update, false, true)
|
||||
weather.timer_forecast = helpers.newtimer("weather_forecast-" .. city_id, timeout, weather.forecast_update, false, true)
|
||||
|
||||
return setmetatable(weather, { __index = weather.widget })
|
||||
return weather
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
|||
Subproject commit 7e4865822c669a86007d88bf6ae846a95c5eed5f
|
||||
Subproject commit 6d6fb0eb073e204c154e4d94b60472d858fc870d
|
Loading…
Reference in New Issue