mirror of https://github.com/lcpz/lain.git
#293: eradicate proxy widget
This commit is contained in:
parent
752ba7fa3d
commit
229d2545dd
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 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 })
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 })
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 = {}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
|||
Subproject commit 0af22b80f8dda896a0c8fefd5c7e52413294967d
|
||||
Subproject commit ed824beb75262f9f78e49baa6e1a591220ca5249
|
Loading…
Reference in New Issue