#293: eradicate proxy widget
This commit is contained in:
parent
752ba7fa3d
commit
229d2545dd
22 changed files with 54 additions and 42 deletions
12
helpers.lua
12
helpers.lua
|
@ -7,6 +7,8 @@
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
local easy_async = require("awful.spawn").easy_async
|
||||||
|
local timer = require("gears.timer")
|
||||||
local debug = require("debug")
|
local debug = require("debug")
|
||||||
local io = { lines = io.lines,
|
local io = { lines = io.lines,
|
||||||
open = io.open,
|
open = io.open,
|
||||||
|
@ -14,10 +16,6 @@ local io = { lines = io.lines,
|
||||||
local rawget = rawget
|
local rawget = rawget
|
||||||
local table = { sort = table.sort }
|
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 helper functions for internal use
|
||||||
-- lain.helpers
|
-- lain.helpers
|
||||||
local helpers = {}
|
local helpers = {}
|
||||||
|
@ -177,12 +175,6 @@ function helpers.spairs(t)
|
||||||
end
|
end
|
||||||
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
|
return helpers
|
||||||
|
|
|
@ -14,14 +14,16 @@ local setmetatable = setmetatable
|
||||||
-- lain.widgets.abase
|
-- lain.widgets.abase
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local abase = helpers.make_widget_textbox()
|
local abase = { widget = wibox.widget.textbox() }
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 5
|
local timeout = args.timeout or 5
|
||||||
local nostart = args.nostart or false
|
local nostart = args.nostart or false
|
||||||
local stoppable = args.stoppable or false
|
local stoppable = args.stoppable or false
|
||||||
local cmd = args.cmd or ""
|
local cmd = args.cmd
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
|
abase.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
function abase.update()
|
function abase.update()
|
||||||
helpers.async(cmd, function(f)
|
helpers.async(cmd, function(f)
|
||||||
output = f
|
output = f
|
||||||
|
|
|
@ -16,9 +16,9 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- ALSA volume
|
-- ALSA volume
|
||||||
-- lain.widgets.alsa
|
-- lain.widgets.alsa
|
||||||
local alsa = helpers.make_widget_textbox()
|
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
|
local alsa = { widget = wibox.widget.textbox() }
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 5
|
local timeout = args.timeout or 5
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
@ -53,4 +53,4 @@ local function worker(args)
|
||||||
return alsa
|
return alsa
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(alsa, { __call = function(_, ...) return worker(...) end })
|
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
|
||||||
|
|
|
@ -14,12 +14,12 @@ local setmetatable = setmetatable
|
||||||
-- lain.widgets.base
|
-- lain.widgets.base
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local base = helpers.make_widget_textbox()
|
local base = { widget = wibox.widget.textbox() }
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 5
|
local timeout = args.timeout or 5
|
||||||
local nostart = args.nostart or false
|
local nostart = args.nostart or false
|
||||||
local stoppable = args.stoppable or false
|
local stoppable = args.stoppable or false
|
||||||
local cmd = args.cmd or ""
|
local cmd = args.cmd
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
function base.update()
|
function base.update()
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
local first_line = require("lain.helpers").first_line
|
local first_line = require("lain.helpers").first_line
|
||||||
local make_widget = require("lain.helpers").make_widget_textbox
|
|
||||||
local newtimer = require("lain.helpers").newtimer
|
local newtimer = require("lain.helpers").newtimer
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
|
@ -26,7 +25,7 @@ local setmetatable = setmetatable
|
||||||
-- lain.widgets.bat
|
-- lain.widgets.bat
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local bat = make_widget()
|
local bat = { widget = wibox.widget.textbox() }
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 30
|
local timeout = args.timeout or 30
|
||||||
local batteries = args.batteries or (args.battery and {args.battery}) or {"BAT0"}
|
local batteries = args.batteries or (args.battery and {args.battery}) or {"BAT0"}
|
||||||
|
@ -176,7 +175,7 @@ local function worker(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
newtimer("batteries", timeout, bat.update)
|
newtimer("batteries", timeout, bat.update)
|
||||||
|
|
||||||
return bat
|
return bat
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ function calendar.hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
function calendar.show(t_out, inc_offset, scr)
|
function calendar.show(t_out, inc_offset, scr)
|
||||||
|
calendar.hide()
|
||||||
|
|
||||||
local today = os.date("%d")
|
local today = os.date("%d")
|
||||||
local offs = inc_offset or 0
|
local offs = inc_offset or 0
|
||||||
local f
|
local f
|
||||||
|
|
|
@ -19,7 +19,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- Google Play Music Desktop infos
|
-- Google Play Music Desktop infos
|
||||||
-- lain.widget.contrib.gpmdp
|
-- lain.widget.contrib.gpmdp
|
||||||
local gpmdp = helpers.make_widget_textbox()
|
local gpmdp = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
|
@ -30,6 +30,8 @@ local function worker(args)
|
||||||
os.getenv("HOME") .. "/.config/Google Play Music Desktop Player/json_store/playback.json"
|
os.getenv("HOME") .. "/.config/Google Play Music Desktop Player/json_store/playback.json"
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
|
gpmdp.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
gpmdp_notification_preset = {
|
gpmdp_notification_preset = {
|
||||||
title = "Now playing",
|
title = "Now playing",
|
||||||
timeout = 6
|
timeout = 6
|
||||||
|
|
|
@ -16,7 +16,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- Keyboard layout switcher
|
-- Keyboard layout switcher
|
||||||
-- lain.widgets.contrib.kblayout
|
-- lain.widgets.contrib.kblayout
|
||||||
local kbdlayout = helpers.make_widget_textbox()
|
local kbdlayout = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
|
@ -28,6 +28,8 @@ local function worker(args)
|
||||||
|
|
||||||
if args.add_us_secondary == false then add_us_secondary = false end
|
if args.add_us_secondary == false then add_us_secondary = false end
|
||||||
|
|
||||||
|
kbdlayout.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
local function kbd_run_settings(layout, variant)
|
local function kbd_run_settings(layout, variant)
|
||||||
kbdlayout_now = {
|
kbdlayout_now = {
|
||||||
layout = string.match(layout, "[^,]+"), -- Make sure to match the primary layout only.
|
layout = string.match(layout, "[^,]+"), -- Make sure to match the primary layout only.
|
||||||
|
|
|
@ -19,7 +19,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- MOC audio player
|
-- MOC audio player
|
||||||
-- lain.widgets.contrib.moc
|
-- lain.widgets.contrib.moc
|
||||||
local moc = helpers.make_widget_textbox()
|
local moc = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
|
@ -31,6 +31,8 @@ local function worker(args)
|
||||||
local followtag = args.followtag or false
|
local followtag = args.followtag or false
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
|
moc.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
moc_notification_preset = { title = "Now playing", timeout = 6 }
|
moc_notification_preset = { title = "Now playing", timeout = 6 }
|
||||||
|
|
||||||
helpers.set_map("current moc track", nil)
|
helpers.set_map("current moc track", nil)
|
||||||
|
|
|
@ -28,7 +28,7 @@ local smapi = require("smapi")
|
||||||
|
|
||||||
-- ThinkPad SMAPI-enabled battery info widget
|
-- ThinkPad SMAPI-enabled battery info widget
|
||||||
-- lain.widgets.contrib.tpbat
|
-- lain.widgets.contrib.tpbat
|
||||||
local tpbat = { }
|
local tpbat = {}
|
||||||
|
|
||||||
function tpbat.hide()
|
function tpbat.hide()
|
||||||
if not tpbat.notification then return end
|
if not tpbat.notification then return end
|
||||||
|
@ -39,7 +39,7 @@ end
|
||||||
function tpbat.show(t_out)
|
function tpbat.show(t_out)
|
||||||
tpbat.hide()
|
tpbat.hide()
|
||||||
|
|
||||||
local bat = tpbat.bat
|
local bat = tpbat.bat
|
||||||
|
|
||||||
if bat == nil or not bat:installed() then return end
|
if bat == nil or not bat:installed() then return end
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,14 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- CPU usage
|
-- CPU usage
|
||||||
-- lain.widgets.cpu
|
-- lain.widgets.cpu
|
||||||
local cpu = helpers.make_widget_textbox()
|
local cpu = { core = {} }
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 2
|
local timeout = args.timeout or 2
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
cpu.core = {}
|
cpu.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
function update()
|
function update()
|
||||||
-- Read the amount of time the CPUs have spent performing
|
-- Read the amount of time the CPUs have spent performing
|
||||||
|
@ -67,9 +67,9 @@ local function worker(args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
widget = cpu.widget
|
|
||||||
cpu_now = cpu.core
|
cpu_now = cpu.core
|
||||||
cpu_now.usage = cpu_now[0].usage
|
cpu_now.usage = cpu_now[0].usage
|
||||||
|
widget = cpu.widget
|
||||||
|
|
||||||
settings()
|
settings()
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,10 +20,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- File system disk space usage
|
-- File system disk space usage
|
||||||
-- lain.widgets.fs
|
-- lain.widgets.fs
|
||||||
local fs = helpers.make_widget_textbox()
|
local fs = { unit = { ["mb"] = 1024, ["gb"] = 1024^2 } }
|
||||||
|
|
||||||
-- Unit definitions
|
|
||||||
fs.unit = { ["mb"] = 1024, ["gb"] = 1024^2 }
|
|
||||||
|
|
||||||
function fs.hide()
|
function fs.hide()
|
||||||
if not fs.notification then return end
|
if not fs.notification then return end
|
||||||
|
@ -68,6 +65,8 @@ local function worker(args)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fs.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
helpers.set_map(partition, false)
|
helpers.set_map(partition, false)
|
||||||
|
|
||||||
function fs.update()
|
function fs.update()
|
||||||
|
@ -125,7 +124,7 @@ local function worker(args)
|
||||||
|
|
||||||
helpers.newtimer(partition, timeout, fs.update)
|
helpers.newtimer(partition, timeout, fs.update)
|
||||||
|
|
||||||
return setmetatable(fs, { __index = fs.widget })
|
return fs
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
|
||||||
|
|
|
@ -19,7 +19,7 @@ local setmetatable = setmetatable
|
||||||
-- lain.widgets.imap
|
-- lain.widgets.imap
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local imap = helpers.make_widget_textbox()
|
local imap = { widget = wibox.widget.textbox() }
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local server = args.server
|
local server = args.server
|
||||||
local mail = args.mail
|
local mail = args.mail
|
||||||
|
|
|
@ -18,7 +18,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- Maildir check (synchronous)
|
-- Maildir check (synchronous)
|
||||||
-- lain.widgets.maildir
|
-- lain.widgets.maildir
|
||||||
local maildir = helpers.make_widget_textbox()
|
local maildir = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
|
@ -28,6 +28,8 @@ local function worker(args)
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
local cmd = args.cmd
|
local cmd = args.cmd
|
||||||
|
|
||||||
|
maildir.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
function maildir.update()
|
function maildir.update()
|
||||||
if cmd then helpers.async({ awful.util.shell, "-c", cmd }, function() end) end
|
if cmd then helpers.async({ awful.util.shell, "-c", cmd }, function() end) end
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,15 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- Memory usage (ignoring caches)
|
-- Memory usage (ignoring caches)
|
||||||
-- lain.widgets.mem
|
-- lain.widgets.mem
|
||||||
local mem = helpers.make_widget_textbox()
|
local mem = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 2
|
local timeout = args.timeout or 2
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
|
mem.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
function update()
|
function update()
|
||||||
mem_now = {}
|
mem_now = {}
|
||||||
for line in lines("/proc/meminfo") do
|
for line in lines("/proc/meminfo") do
|
||||||
|
|
|
@ -21,7 +21,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- MPD infos
|
-- MPD infos
|
||||||
-- lain.widgets.mpd
|
-- lain.widgets.mpd
|
||||||
local mpd = helpers.make_widget_textbox()
|
local mpd = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
|
@ -41,6 +41,8 @@ local function worker(args)
|
||||||
local echo = string.format("printf \"%sstatus\\ncurrentsong\\nclose\\n\"", password)
|
local echo = string.format("printf \"%sstatus\\ncurrentsong\\nclose\\n\"", password)
|
||||||
local cmd = string.format("%s | curl --connect-timeout 1 -fsm 3 %s", echo, mpdh)
|
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 }
|
mpd_notification_preset = { title = "Now playing", timeout = 6 }
|
||||||
|
|
||||||
helpers.set_map("current mpd track", nil)
|
helpers.set_map("current mpd track", nil)
|
||||||
|
|
|
@ -18,7 +18,7 @@ local setmetatable = setmetatable
|
||||||
-- lain.widgets.net
|
-- lain.widgets.net
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local net = helpers.make_widget_textbox()
|
local net = { widget = wibox.widget.textbox() }
|
||||||
net.last_t = 0
|
net.last_t = 0
|
||||||
net.last_r = 0
|
net.last_r = 0
|
||||||
net.devices = {}
|
net.devices = {}
|
||||||
|
|
|
@ -16,7 +16,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- PulseAudio volume
|
-- PulseAudio volume
|
||||||
-- lain.widgets.pulseaudio
|
-- lain.widgets.pulseaudio
|
||||||
local pulseaudio = helpers.make_widget_textbox()
|
local pulseaudio = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
|
@ -26,6 +26,8 @@ local function worker(args)
|
||||||
|
|
||||||
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.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()
|
function pulseaudio.update()
|
||||||
if scallback then pulseaudio.cmd = scallback() end
|
if scallback then pulseaudio.cmd = scallback() end
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,15 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- System load
|
-- System load
|
||||||
-- lain.widgets.sysload
|
-- lain.widgets.sysload
|
||||||
local sysload = helpers.make_widget_textbox()
|
local sysload = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 2
|
local timeout = args.timeout or 2
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
|
sysload.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
function update()
|
function update()
|
||||||
local f = io.open("/proc/loadavg")
|
local f = io.open("/proc/loadavg")
|
||||||
local ret = f:read("*all")
|
local ret = f:read("*all")
|
||||||
|
|
|
@ -14,7 +14,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- coretemp
|
-- coretemp
|
||||||
-- lain.widgets.temp
|
-- lain.widgets.temp
|
||||||
local temp = helpers.make_widget_textbox()
|
local temp = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
|
@ -22,6 +22,8 @@ local function worker(args)
|
||||||
local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
|
local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
|
temp.widget = wibox.widget.textbox()
|
||||||
|
|
||||||
function update()
|
function update()
|
||||||
local f = io.open(tempfile)
|
local f = io.open(tempfile)
|
||||||
if f then
|
if f then
|
||||||
|
|
|
@ -25,7 +25,7 @@ local setmetatable = setmetatable
|
||||||
-- lain.widgets.weather
|
-- lain.widgets.weather
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
local weather = helpers.make_widget_textbox()
|
local weather = { widget = wibox.widget.textbox() }
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default
|
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default
|
||||||
local timeout = args.timeout or 900 -- 15 min
|
local timeout = args.timeout or 900 -- 15 min
|
||||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
||||||
Subproject commit 0af22b80f8dda896a0c8fefd5c7e52413294967d
|
Subproject commit ed824beb75262f9f78e49baa6e1a591220ca5249
|
Loading…
Add table
Reference in a new issue