This commit is contained in:
parent
2a5d13920f
commit
8f948b52eb
12 changed files with 110 additions and 136 deletions
|
@ -15,13 +15,13 @@ local math = { modf = math.modf }
|
||||||
local string = { format = string.format,
|
local string = { format = string.format,
|
||||||
match = string.match,
|
match = string.match,
|
||||||
rep = string.rep }
|
rep = string.rep }
|
||||||
local type = type
|
local type, tonumber = type, tonumber
|
||||||
local tonumber = tonumber
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- ALSA volume bar
|
-- ALSA volume bar
|
||||||
-- lain.widget.alsabar
|
-- lain.widget.alsabar
|
||||||
local alsabar = {
|
|
||||||
|
local function factory(args)
|
||||||
|
local alsabar = {
|
||||||
colors = {
|
colors = {
|
||||||
background = "#000000",
|
background = "#000000",
|
||||||
mute = "#EB8F8F",
|
mute = "#EB8F8F",
|
||||||
|
@ -30,9 +30,8 @@ local alsabar = {
|
||||||
|
|
||||||
_current_level = 0,
|
_current_level = 0,
|
||||||
_muted = false
|
_muted = false
|
||||||
}
|
}
|
||||||
|
|
||||||
local function factory(args)
|
|
||||||
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
|
||||||
|
@ -133,4 +132,4 @@ local function factory(args)
|
||||||
return alsabar
|
return alsabar
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(alsabar, { __call = function(_, ...) return factory(...) end })
|
return factory
|
||||||
|
|
|
@ -15,13 +15,12 @@ local wibox = require("wibox")
|
||||||
local os = { getenv = os.getenv }
|
local os = { getenv = os.getenv }
|
||||||
local string = { format = string.format,
|
local string = { format = string.format,
|
||||||
gmatch = string.gmatch }
|
gmatch = string.gmatch }
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- MOC audio player
|
-- MOC audio player
|
||||||
-- lain.widget.contrib.moc
|
-- lain.widget.contrib.moc
|
||||||
local moc = {}
|
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
|
local moc = { widget = wibox.widget.textbox() }
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 2
|
local timeout = args.timeout or 2
|
||||||
local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
|
local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
|
||||||
|
@ -31,8 +30,6 @@ local function factory(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)
|
||||||
|
@ -98,4 +95,4 @@ local function factory(args)
|
||||||
return moc
|
return moc
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(moc, { __call = function(_, ...) return factory(...) end })
|
return factory
|
||||||
|
|
|
@ -13,19 +13,16 @@ local math = { ceil = math.ceil }
|
||||||
local string = { format = string.format,
|
local string = { format = string.format,
|
||||||
gmatch = string.gmatch }
|
gmatch = string.gmatch }
|
||||||
local tostring = tostring
|
local tostring = tostring
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- CPU usage
|
-- CPU usage
|
||||||
-- lain.widget.cpu
|
-- lain.widget.cpu
|
||||||
local cpu = { core = {} }
|
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
|
local cpu = { core = {}, widget = wibox.widget.textbox() }
|
||||||
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.widget = wibox.widget.textbox()
|
|
||||||
|
|
||||||
function cpu.update()
|
function cpu.update()
|
||||||
-- Read the amount of time the CPUs have spent performing
|
-- Read the amount of time the CPUs have spent performing
|
||||||
-- different kinds of work. Read the first line of /proc/stat
|
-- different kinds of work. Read the first line of /proc/stat
|
||||||
|
@ -79,4 +76,4 @@ local function factory(args)
|
||||||
return cpu
|
return cpu
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(cpu, { __call = function(_, ...) return factory(...) end })
|
return factory
|
||||||
|
|
|
@ -13,21 +13,21 @@ local wibox = require("wibox")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local string = string
|
local string = string
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- File system disk space usage
|
-- File system disk space usage
|
||||||
-- lain.widget.fs
|
-- lain.widget.fs
|
||||||
local fs = { unit = { ["mb"] = 1024, ["gb"] = 1024^2 } }
|
|
||||||
|
|
||||||
function fs.hide()
|
local function factory(args)
|
||||||
|
local fs = { unit = { ["mb"] = 1024, ["gb"] = 1024^2 }, widget = wibox.widget.textbox() }
|
||||||
|
|
||||||
|
function fs.hide()
|
||||||
if not fs.notification then return end
|
if not fs.notification then return end
|
||||||
naughty.destroy(fs.notification)
|
naughty.destroy(fs.notification)
|
||||||
fs.notification = nil
|
fs.notification = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function fs.show(seconds, scr)
|
function fs.show(seconds, scr)
|
||||||
fs.update()
|
fs.update()
|
||||||
|
|
||||||
fs.hide()
|
fs.hide()
|
||||||
|
|
||||||
if fs.followtag then
|
if fs.followtag then
|
||||||
|
@ -40,9 +40,8 @@ function fs.show(seconds, scr)
|
||||||
preset = fs.notification_preset,
|
preset = fs.notification_preset,
|
||||||
timeout = seconds or 5
|
timeout = seconds or 5
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function factory(args)
|
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 600
|
local timeout = args.timeout or 600
|
||||||
local partition = args.partition or "/"
|
local partition = args.partition or "/"
|
||||||
|
@ -62,8 +61,6 @@ local function factory(args)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
fs.widget = wibox.widget.textbox()
|
|
||||||
|
|
||||||
helpers.set_map(partition, false)
|
helpers.set_map(partition, false)
|
||||||
|
|
||||||
function fs.update()
|
function fs.update()
|
||||||
|
@ -124,4 +121,4 @@ local function factory(args)
|
||||||
return fs
|
return fs
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(fs, { __call = function(_, ...) return factory(...) end })
|
return factory
|
||||||
|
|
|
@ -9,22 +9,17 @@
|
||||||
|
|
||||||
local helpers = require("lain.helpers")
|
local helpers = require("lain.helpers")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local gmatch = string.gmatch
|
local gmatch, lines, floor = string.gmatch, io.lines, math.floor
|
||||||
local lines = io.lines
|
|
||||||
local floor = math.floor
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- Memory usage (ignoring caches)
|
-- Memory usage (ignoring caches)
|
||||||
-- lain.widget.mem
|
-- lain.widget.mem
|
||||||
local mem = {}
|
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
|
local mem = { widget = wibox.widget.textbox() }
|
||||||
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 mem.update()
|
function mem.update()
|
||||||
mem_now = {}
|
mem_now = {}
|
||||||
for line in lines("/proc/meminfo") do
|
for line in lines("/proc/meminfo") do
|
||||||
|
@ -53,4 +48,4 @@ local function factory(args)
|
||||||
return mem
|
return mem
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(mem, { __call = function(_, ...) return factory(...) end })
|
return factory
|
||||||
|
|
|
@ -17,13 +17,12 @@ local os = { getenv = os.getenv }
|
||||||
local string = { format = string.format,
|
local string = { format = string.format,
|
||||||
gmatch = string.gmatch,
|
gmatch = string.gmatch,
|
||||||
match = string.match }
|
match = string.match }
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- MPD infos
|
-- MPD infos
|
||||||
-- lain.widget.mpd
|
-- lain.widget.mpd
|
||||||
local mpd = {}
|
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
|
local mpd = { widget = wibox.widget.textbox() }
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 2
|
local timeout = args.timeout or 2
|
||||||
local password = (args.password and #args.password > 0 and string.format("password %s\\n", args.password)) or ""
|
local password = (args.password and #args.password > 0 and string.format("password %s\\n", args.password)) or ""
|
||||||
|
@ -41,8 +40,6 @@ local function factory(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)
|
||||||
|
@ -112,7 +109,8 @@ local function factory(args)
|
||||||
|
|
||||||
if not string.match(mpd_now.file, "http.*://") then -- local file instead of http stream
|
if not string.match(mpd_now.file, "http.*://") then -- local file instead of http stream
|
||||||
local path = string.format("%s/%s", music_dir, string.match(mpd_now.file, ".*/"))
|
local path = string.format("%s/%s", music_dir, string.match(mpd_now.file, ".*/"))
|
||||||
local cover = string.format("find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'", path:gsub("'", "'\\''"), cover_pattern)
|
local cover = string.format("find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'",
|
||||||
|
path:gsub("'", "'\\''"), cover_pattern)
|
||||||
helpers.async({ shell, "-c", cover }, function(current_icon)
|
helpers.async({ shell, "-c", cover }, function(current_icon)
|
||||||
common.icon = current_icon:gsub("\n", "")
|
common.icon = current_icon:gsub("\n", "")
|
||||||
if #common.icon == 0 then common.icon = nil end
|
if #common.icon == 0 then common.icon = nil end
|
||||||
|
@ -134,4 +132,4 @@ local function factory(args)
|
||||||
return mpd
|
return mpd
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(mpd, { __call = function(_, ...) return factory(...) end })
|
return factory
|
||||||
|
|
|
@ -17,7 +17,6 @@ local string = { format = string.format, match = string.match }
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local net = { widget = wibox.widget.textbox(), devices = {} }
|
local net = { widget = wibox.widget.textbox(), devices = {} }
|
||||||
|
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 2
|
local timeout = args.timeout or 2
|
||||||
local units = args.units or 1024 -- KB
|
local units = args.units or 1024 -- KB
|
||||||
|
|
|
@ -13,16 +13,16 @@ local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local math = { modf = math.modf }
|
local math = { modf = math.modf }
|
||||||
local string = { format = string.format,
|
local string = { format = string.format,
|
||||||
gmatch = string.gmatch,
|
|
||||||
match = string.match,
|
match = string.match,
|
||||||
|
gmatch = string.gmatch,
|
||||||
rep = string.rep }
|
rep = string.rep }
|
||||||
local type = type
|
local type, tonumber = type, tonumber
|
||||||
local tonumber = tonumber
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- Pulseaudio volume bar
|
-- Pulseaudio volume bar
|
||||||
-- lain.widget.pulsebar
|
-- lain.widget.pulsebar
|
||||||
local pulsebar = {
|
|
||||||
|
local function factory(args)
|
||||||
|
local pulsebar = {
|
||||||
colors = {
|
colors = {
|
||||||
background = "#000000",
|
background = "#000000",
|
||||||
mute = "#EB8F8F",
|
mute = "#EB8F8F",
|
||||||
|
@ -31,9 +31,8 @@ local pulsebar = {
|
||||||
|
|
||||||
_current_level = 0,
|
_current_level = 0,
|
||||||
_muted = false
|
_muted = false
|
||||||
}
|
}
|
||||||
|
|
||||||
local function factory(args)
|
|
||||||
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
|
||||||
|
|
|
@ -9,27 +9,23 @@
|
||||||
|
|
||||||
local helpers = require("lain.helpers")
|
local helpers = require("lain.helpers")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local io = { open = io.open }
|
local open, match = io.open, string.match
|
||||||
local string = { match = string.match }
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- System load
|
-- System load
|
||||||
-- lain.widget.sysload
|
-- lain.widget.sysload
|
||||||
local sysload = {}
|
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
|
local sysload = { widget = wibox.widget.textbox() }
|
||||||
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 sysload.update()
|
function sysload.update()
|
||||||
local f = io.open("/proc/loadavg")
|
local f = open("/proc/loadavg")
|
||||||
local ret = f:read("*all")
|
local ret = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
load_1, load_5, load_15 = string.match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
|
load_1, load_5, load_15 = match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
|
||||||
|
|
||||||
widget = sysload.widget
|
widget = sysload.widget
|
||||||
settings()
|
settings()
|
||||||
|
@ -40,4 +36,4 @@ local function factory(args)
|
||||||
return sysload
|
return sysload
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(sysload, { __call = function(_, ...) return factory(...) end })
|
return factory
|
||||||
|
|
|
@ -8,24 +8,21 @@
|
||||||
|
|
||||||
local helpers = require("lain.helpers")
|
local helpers = require("lain.helpers")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local io = { open = io.open }
|
local open = io.open
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- coretemp
|
-- coretemp
|
||||||
-- lain.widget.temp
|
-- lain.widget.temp
|
||||||
local temp = {}
|
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
|
local temp = { widget = wibox.widget.textbox() }
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 2
|
local timeout = args.timeout or 2
|
||||||
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 temp.update()
|
function temp.update()
|
||||||
local f = io.open(tempfile)
|
local f = open(tempfile)
|
||||||
if f then
|
if f then
|
||||||
coretemp_now = tonumber(f:read("*all")) / 1000
|
coretemp_now = tonumber(f:read("*all")) / 1000
|
||||||
f:close()
|
f:close()
|
||||||
|
@ -42,4 +39,4 @@ local function factory(args)
|
||||||
return temp
|
return temp
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(temp, { __call = function(_, ...) return factory(...) end })
|
return factory
|
||||||
|
|
Loading…
Add table
Reference in a new issue