From: copycat-killer Date: Thu, 26 Jan 2017 19:53:55 +0000 (+0100) Subject: #293: eradicate proxy widget X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/229d2545dd399b52c6128a823657c6266fbbe8a9?ds=sidebyside;hp=--cc #293: eradicate proxy widget --- 229d2545dd399b52c6128a823657c6266fbbe8a9 diff --git a/helpers.lua b/helpers.lua index 0305722..f32c4ad 100644 --- a/helpers.lua +++ b/helpers.lua @@ -7,6 +7,8 @@ --]] +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, @@ -14,10 +16,6 @@ local io = { lines = io.lines, 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 = {} @@ -177,12 +175,6 @@ function helpers.spairs(t) 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 diff --git a/widgets/abase.lua b/widgets/abase.lua index 1214151..409495b 100644 --- a/widgets/abase.lua +++ b/widgets/abase.lua @@ -14,14 +14,16 @@ local setmetatable = setmetatable -- 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 diff --git a/widgets/alsa.lua b/widgets/alsa.lua index 8139d42..f73194b 100644 --- a/widgets/alsa.lua +++ b/widgets/alsa.lua @@ -16,9 +16,9 @@ local setmetatable = setmetatable -- 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 @@ -53,4 +53,4 @@ local function worker(args) return alsa end -return setmetatable(alsa, { __call = function(_, ...) return worker(...) end }) +return setmetatable({}, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/base.lua b/widgets/base.lua index 9d7b710..2a8f507 100644 --- a/widgets/base.lua +++ b/widgets/base.lua @@ -14,12 +14,12 @@ local setmetatable = setmetatable -- 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() diff --git a/widgets/bat.lua b/widgets/bat.lua index 503c56e..e479fd9 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -8,7 +8,6 @@ --]] 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") @@ -26,7 +25,7 @@ local setmetatable = setmetatable -- 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"} @@ -176,7 +175,7 @@ local function worker(args) end newtimer("batteries", timeout, bat.update) - + return bat end diff --git a/widgets/calendar.lua b/widgets/calendar.lua index 892d954..032b1fb 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -24,6 +24,8 @@ function calendar.hide() end function calendar.show(t_out, inc_offset, scr) + calendar.hide() + local today = os.date("%d") local offs = inc_offset or 0 local f diff --git a/widgets/contrib/gpmdp.lua b/widgets/contrib/gpmdp.lua index 37da43d..94076c8 100644 --- a/widgets/contrib/gpmdp.lua +++ b/widgets/contrib/gpmdp.lua @@ -19,7 +19,7 @@ local setmetatable = setmetatable -- 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 {} @@ -30,6 +30,8 @@ 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 diff --git a/widgets/contrib/kbdlayout.lua b/widgets/contrib/kbdlayout.lua index 8132c77..08e7bd0 100644 --- a/widgets/contrib/kbdlayout.lua +++ b/widgets/contrib/kbdlayout.lua @@ -16,7 +16,7 @@ local setmetatable = setmetatable -- Keyboard layout switcher -- lain.widgets.contrib.kblayout -local kbdlayout = helpers.make_widget_textbox() +local kbdlayout = {} local function worker(args) local args = args or {} @@ -28,6 +28,8 @@ local function worker(args) 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. diff --git a/widgets/contrib/moc.lua b/widgets/contrib/moc.lua index 3566985..6fe96a1 100644 --- a/widgets/contrib/moc.lua +++ b/widgets/contrib/moc.lua @@ -19,7 +19,7 @@ local setmetatable = setmetatable -- MOC audio player -- lain.widgets.contrib.moc -local moc = helpers.make_widget_textbox() +local moc = {} local function worker(args) local args = args or {} @@ -31,6 +31,8 @@ local function worker(args) 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) diff --git a/widgets/contrib/tpbat/init.lua b/widgets/contrib/tpbat/init.lua index 32a2527..e65cde8 100644 --- a/widgets/contrib/tpbat/init.lua +++ b/widgets/contrib/tpbat/init.lua @@ -28,7 +28,7 @@ local smapi = require("smapi") -- ThinkPad SMAPI-enabled battery info widget -- lain.widgets.contrib.tpbat -local tpbat = { } +local tpbat = {} function tpbat.hide() if not tpbat.notification then return end @@ -39,7 +39,7 @@ 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 diff --git a/widgets/cpu.lua b/widgets/cpu.lua index f61e2cc..79f99af 100644 --- a/widgets/cpu.lua +++ b/widgets/cpu.lua @@ -17,14 +17,14 @@ local setmetatable = setmetatable -- 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 @@ -67,9 +67,9 @@ local function worker(args) end end - widget = cpu.widget cpu_now = cpu.core cpu_now.usage = cpu_now[0].usage + widget = cpu.widget settings() end diff --git a/widgets/fs.lua b/widgets/fs.lua index efd31fb..c78b6cb 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -20,10 +20,7 @@ local setmetatable = setmetatable -- 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 @@ -68,6 +65,8 @@ local function worker(args) } end + fs.widget = wibox.widget.textbox() + helpers.set_map(partition, false) function fs.update() @@ -125,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 }) diff --git a/widgets/imap.lua b/widgets/imap.lua index 770a1bc..95d35fd 100644 --- a/widgets/imap.lua +++ b/widgets/imap.lua @@ -19,7 +19,7 @@ local setmetatable = setmetatable -- 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 diff --git a/widgets/maildir.lua b/widgets/maildir.lua index 7e7b246..f7dfd28 100644 --- a/widgets/maildir.lua +++ b/widgets/maildir.lua @@ -18,7 +18,7 @@ local setmetatable = setmetatable -- Maildir check (synchronous) -- lain.widgets.maildir -local maildir = helpers.make_widget_textbox() +local maildir = {} local function worker(args) local args = args or {} @@ -28,6 +28,8 @@ local function worker(args) 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 diff --git a/widgets/mem.lua b/widgets/mem.lua index ff5816c..2b414ef 100644 --- a/widgets/mem.lua +++ b/widgets/mem.lua @@ -16,13 +16,15 @@ local setmetatable = setmetatable -- 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 diff --git a/widgets/mpd.lua b/widgets/mpd.lua index d92c78f..c4c4691 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -21,7 +21,7 @@ local setmetatable = setmetatable -- MPD infos -- lain.widgets.mpd -local mpd = helpers.make_widget_textbox() +local mpd = {} local function worker(args) local args = args or {} @@ -41,6 +41,8 @@ local function worker(args) 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) diff --git a/widgets/net.lua b/widgets/net.lua index 302559a..1dfef43 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -18,7 +18,7 @@ local setmetatable = setmetatable -- 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 = {} diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index 8e89ffd..68d3066 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -16,7 +16,7 @@ local setmetatable = setmetatable -- PulseAudio volume -- lain.widgets.pulseaudio -local pulseaudio = helpers.make_widget_textbox() +local pulseaudio = {} local function worker(args) 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.widget = wibox.widget.textbox() + function pulseaudio.update() if scallback then pulseaudio.cmd = scallback() end diff --git a/widgets/sysload.lua b/widgets/sysload.lua index 148319d..49f640c 100644 --- a/widgets/sysload.lua +++ b/widgets/sysload.lua @@ -15,13 +15,15 @@ local setmetatable = setmetatable -- 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") diff --git a/widgets/temp.lua b/widgets/temp.lua index 4d8a727..9f41fdb 100644 --- a/widgets/temp.lua +++ b/widgets/temp.lua @@ -14,7 +14,7 @@ local setmetatable = setmetatable -- coretemp -- lain.widgets.temp -local temp = helpers.make_widget_textbox() +local temp = {} local function worker(args) local args = args or {} @@ -22,6 +22,8 @@ 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 diff --git a/widgets/weather.lua b/widgets/weather.lua index 9f83dc8..febd73b 100644 --- a/widgets/weather.lua +++ b/widgets/weather.lua @@ -25,7 +25,7 @@ local setmetatable = setmetatable -- 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 diff --git a/wiki b/wiki index 0af22b8..ed824be 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 0af22b80f8dda896a0c8fefd5c7e52413294967d +Subproject commit ed824beb75262f9f78e49baa6e1a591220ca5249