--]]
+local easy_async = require("awful.spawn").easy_async
+local timer = require("gears.timer")
local debug = require("debug")
local io = { lines = io.lines,
open = io.open,
local rawget = rawget
local table = { sort = table.sort }
-local easy_async = require("awful.spawn").easy_async
-local timer = require("gears.timer")
-local wibox = require("wibox")
-
-- Lain helper functions for internal use
-- lain.helpers
local helpers = {}
end
end
--- create a lain textbox
-function helpers.make_widget_textbox()
- local w = { widget = wibox.widget.textbox() }
- return setmetatable(w, { __index = w.widget })
-end
-
-- }}}
return helpers
-- lain.widgets.abase
local function worker(args)
- local abase = helpers.make_widget_textbox()
+ local abase = { widget = wibox.widget.textbox() }
local args = args or {}
local timeout = args.timeout or 5
local nostart = args.nostart or false
local stoppable = args.stoppable or false
- local cmd = args.cmd or ""
+ local cmd = args.cmd
local settings = args.settings or function() end
+ abase.widget = wibox.widget.textbox()
+
function abase.update()
helpers.async(cmd, function(f)
output = f
-- ALSA volume
-- lain.widgets.alsa
-local alsa = helpers.make_widget_textbox()
local function worker(args)
+ local alsa = { widget = wibox.widget.textbox() }
local args = args or {}
local timeout = args.timeout or 5
local settings = args.settings or function() end
return alsa
end
-return setmetatable(alsa, { __call = function(_, ...) return worker(...) end })
+return setmetatable({}, { __call = function(_, ...) return worker(...) end })
-- lain.widgets.base
local function worker(args)
- local base = helpers.make_widget_textbox()
+ local base = { widget = wibox.widget.textbox() }
local args = args or {}
local timeout = args.timeout or 5
local nostart = args.nostart or false
local stoppable = args.stoppable or false
- local cmd = args.cmd or ""
+ local cmd = args.cmd
local settings = args.settings or function() end
function base.update()
--]]
local first_line = require("lain.helpers").first_line
-local make_widget = require("lain.helpers").make_widget_textbox
local newtimer = require("lain.helpers").newtimer
local naughty = require("naughty")
local wibox = require("wibox")
-- lain.widgets.bat
local function worker(args)
- local bat = make_widget()
+ local bat = { widget = wibox.widget.textbox() }
local args = args or {}
local timeout = args.timeout or 30
local batteries = args.batteries or (args.battery and {args.battery}) or {"BAT0"}
end
newtimer("batteries", timeout, bat.update)
-
+
return bat
end
end
function calendar.show(t_out, inc_offset, scr)
+ calendar.hide()
+
local today = os.date("%d")
local offs = inc_offset or 0
local f
-- Google Play Music Desktop infos
-- lain.widget.contrib.gpmdp
-local gpmdp = helpers.make_widget_textbox()
+local gpmdp = {}
local function worker(args)
local args = args or {}
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
-- Keyboard layout switcher
-- lain.widgets.contrib.kblayout
-local kbdlayout = helpers.make_widget_textbox()
+local kbdlayout = {}
local function worker(args)
local args = args or {}
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.
-- MOC audio player
-- lain.widgets.contrib.moc
-local moc = helpers.make_widget_textbox()
+local moc = {}
local function worker(args)
local args = args or {}
local followtag = args.followtag or false
local settings = args.settings or function() end
+ moc.widget = wibox.widget.textbox()
+
moc_notification_preset = { title = "Now playing", timeout = 6 }
helpers.set_map("current moc track", nil)
-- ThinkPad SMAPI-enabled battery info widget
-- lain.widgets.contrib.tpbat
-local tpbat = { }
+local tpbat = {}
function tpbat.hide()
if not tpbat.notification then return end
function tpbat.show(t_out)
tpbat.hide()
- local bat = tpbat.bat
+ local bat = tpbat.bat
if bat == nil or not bat:installed() then return end
-- CPU usage
-- lain.widgets.cpu
-local cpu = helpers.make_widget_textbox()
+local cpu = { core = {} }
local function worker(args)
local args = args or {}
local timeout = args.timeout or 2
local settings = args.settings or function() end
- cpu.core = {}
+ cpu.widget = wibox.widget.textbox()
function update()
-- Read the amount of time the CPUs have spent performing
end
end
- widget = cpu.widget
cpu_now = cpu.core
cpu_now.usage = cpu_now[0].usage
+ widget = cpu.widget
settings()
end
-- File system disk space usage
-- lain.widgets.fs
-local fs = helpers.make_widget_textbox()
-
--- Unit definitions
-fs.unit = { ["mb"] = 1024, ["gb"] = 1024^2 }
+local fs = { unit = { ["mb"] = 1024, ["gb"] = 1024^2 } }
function fs.hide()
if not fs.notification then return end
}
end
+ fs.widget = wibox.widget.textbox()
+
helpers.set_map(partition, false)
function fs.update()
helpers.newtimer(partition, timeout, fs.update)
- return setmetatable(fs, { __index = fs.widget })
+ return fs
end
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
-- lain.widgets.imap
local function worker(args)
- local imap = helpers.make_widget_textbox()
+ local imap = { widget = wibox.widget.textbox() }
local args = args or {}
local server = args.server
local mail = args.mail
-- Maildir check (synchronous)
-- lain.widgets.maildir
-local maildir = helpers.make_widget_textbox()
+local maildir = {}
local function worker(args)
local args = args or {}
local settings = args.settings or function() end
local cmd = args.cmd
+ maildir.widget = wibox.widget.textbox()
+
function maildir.update()
if cmd then helpers.async({ awful.util.shell, "-c", cmd }, function() end) end
-- Memory usage (ignoring caches)
-- lain.widgets.mem
-local mem = helpers.make_widget_textbox()
+local mem = {}
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
-- MPD infos
-- lain.widgets.mpd
-local mpd = helpers.make_widget_textbox()
+local mpd = {}
local function worker(args)
local args = args or {}
local echo = string.format("printf \"%sstatus\\ncurrentsong\\nclose\\n\"", password)
local cmd = string.format("%s | curl --connect-timeout 1 -fsm 3 %s", echo, mpdh)
+ mpd.widget = wibox.widget.textbox()
+
mpd_notification_preset = { title = "Now playing", timeout = 6 }
helpers.set_map("current mpd track", nil)
-- lain.widgets.net
local function worker(args)
- local net = helpers.make_widget_textbox()
+ local net = { widget = wibox.widget.textbox() }
net.last_t = 0
net.last_r = 0
net.devices = {}
-- PulseAudio volume
-- lain.widgets.pulseaudio
-local pulseaudio = helpers.make_widget_textbox()
+local pulseaudio = {}
local function worker(args)
local args = args or {}
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
-- System load
-- lain.widgets.sysload
-local sysload = helpers.make_widget_textbox()
+local sysload = {}
local function worker(args)
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")
-- coretemp
-- lain.widgets.temp
-local temp = helpers.make_widget_textbox()
+local temp = {}
local function worker(args)
local args = args or {}
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
-- lain.widgets.weather
local function worker(args)
- local weather = helpers.make_widget_textbox()
+ local weather = { widget = wibox.widget.textbox() }
local args = args or {}
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default
local timeout = args.timeout or 900 -- 15 min
-Subproject commit 0af22b80f8dda896a0c8fefd5c7e52413294967d
+Subproject commit ed824beb75262f9f78e49baa6e1a591220ca5249