Merge branch 'staticssleever668-master'
This commit is contained in:
commit
9800eee039
27 changed files with 76 additions and 69 deletions
|
@ -109,7 +109,7 @@ end
|
||||||
-- @return cmd PID
|
-- @return cmd PID
|
||||||
function helpers.async(cmd, callback)
|
function helpers.async(cmd, callback)
|
||||||
return spawn.easy_async(cmd,
|
return spawn.easy_async(cmd,
|
||||||
function (stdout, stderr, reason, exit_code)
|
function (stdout, _, _, exit_code)
|
||||||
callback(stdout, exit_code)
|
callback(stdout, exit_code)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -117,7 +117,7 @@ end
|
||||||
-- like above, but call spawn.easy_async with a shell
|
-- like above, but call spawn.easy_async with a shell
|
||||||
function helpers.async_with_shell(cmd, callback)
|
function helpers.async_with_shell(cmd, callback)
|
||||||
return spawn.easy_async_with_shell(cmd,
|
return spawn.easy_async_with_shell(cmd,
|
||||||
function (stdout, stderr, reason, exit_code)
|
function (stdout, _, _, exit_code)
|
||||||
callback(stdout, exit_code)
|
callback(stdout, exit_code)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -125,7 +125,7 @@ local function arrange(p, layout)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function mouse_resize_handler(c, corner, x, y, orientation)
|
local function mouse_resize_handler(c, _, _, _, orientation)
|
||||||
local wa = c.screen.workarea
|
local wa = c.screen.workarea
|
||||||
local mwfact = c.screen.selected_tag.master_width_factor
|
local mwfact = c.screen.selected_tag.master_width_factor
|
||||||
local g = c:geometry()
|
local g = c:geometry()
|
||||||
|
@ -208,7 +208,7 @@ end
|
||||||
local function clients_by_position()
|
local function clients_by_position()
|
||||||
local this = client.focus
|
local this = client.focus
|
||||||
if this then
|
if this then
|
||||||
sorted = client.focus.first_tag:clients()
|
local sorted = client.focus.first_tag:clients()
|
||||||
table.sort(sorted, compare_position)
|
table.sort(sorted, compare_position)
|
||||||
|
|
||||||
local idx = 0
|
local idx = 0
|
||||||
|
|
|
@ -240,7 +240,7 @@ local function do_fair(p, orientation)
|
||||||
for i = 1, (num_x-1) do
|
for i = 1, (num_x-1) do
|
||||||
local height = math.floor(wa.height / num_y[i])
|
local height = math.floor(wa.height / num_y[i])
|
||||||
local wy = wa.y
|
local wy = wa.y
|
||||||
for j = 0, (num_y[i]-2) do
|
for _ = 0, (num_y[i]-2) do
|
||||||
local g = {}
|
local g = {}
|
||||||
g.x = wx
|
g.x = wx
|
||||||
g.y = wy
|
g.y = wy
|
||||||
|
|
|
@ -42,8 +42,8 @@ SOFTWARE.
|
||||||
--]==]
|
--]==]
|
||||||
|
|
||||||
-- global dependencies:
|
-- global dependencies:
|
||||||
local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset =
|
local pairs, type, tostring, tonumber, getmetatable, setmetatable =
|
||||||
pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset
|
pairs, type, tostring, tonumber, getmetatable, setmetatable
|
||||||
local error, require, pcall, select = error, require, pcall, select
|
local error, require, pcall, select = error, require, pcall, select
|
||||||
local floor, huge = math.floor, math.huge
|
local floor, huge = math.floor, math.huge
|
||||||
local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat =
|
local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat =
|
||||||
|
@ -246,7 +246,7 @@ local function exception(reason, value, state, buffer, buflen, defaultmessage)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function json.encodeexception(reason, value, state, defaultmessage)
|
function json.encodeexception(_, _, _, defaultmessage)
|
||||||
return quotestring("<" .. defaultmessage .. ">")
|
return quotestring("<" .. defaultmessage .. ">")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ encode2 = function (value, indent, level, buffer, buflen, tables, globalorder, s
|
||||||
local v = value[k]
|
local v = value[k]
|
||||||
if v then
|
if v then
|
||||||
used[k] = true
|
used[k] = true
|
||||||
buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
|
buflen, _ = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
|
||||||
prev = true -- add a seperator before the next element
|
prev = true -- add a seperator before the next element
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -504,7 +504,6 @@ end
|
||||||
local scanvalue -- forward declaration
|
local scanvalue -- forward declaration
|
||||||
|
|
||||||
local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta)
|
local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta)
|
||||||
local len = strlen (str)
|
|
||||||
local tbl, n = {}, 0
|
local tbl, n = {}, 0
|
||||||
local pos = startpos + 1
|
local pos = startpos + 1
|
||||||
if what == 'object' then
|
if what == 'object' then
|
||||||
|
@ -626,7 +625,7 @@ function json.use_lpeg ()
|
||||||
local PlainChar = 1 - S"\"\\\n\r"
|
local PlainChar = 1 - S"\"\\\n\r"
|
||||||
local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars
|
local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars
|
||||||
local HexDigit = R("09", "af", "AF")
|
local HexDigit = R("09", "af", "AF")
|
||||||
local function UTF16Surrogate (match, pos, high, low)
|
local function UTF16Surrogate (_, _, high, low)
|
||||||
high, low = tonumber (high, 16), tonumber (low, 16)
|
high, low = tonumber (high, 16), tonumber (low, 16)
|
||||||
if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then
|
if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then
|
||||||
return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000)
|
return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000)
|
||||||
|
|
|
@ -39,7 +39,7 @@ function util.menu_clients_current_tags(menu, args)
|
||||||
local t = cls_tags[i]
|
local t = cls_tags[i]
|
||||||
local cls = t:clients()
|
local cls = t:clients()
|
||||||
|
|
||||||
for k, c in pairs(cls) do
|
for _, c in pairs(cls) do
|
||||||
cls_t[#cls_t + 1] = { awful.util.escape(c.name) or "",
|
cls_t[#cls_t + 1] = { awful.util.escape(c.name) or "",
|
||||||
function ()
|
function ()
|
||||||
c.minimized = false
|
c.minimized = false
|
||||||
|
@ -99,7 +99,7 @@ end
|
||||||
function util.tag_view_nonempty(direction, sc)
|
function util.tag_view_nonempty(direction, sc)
|
||||||
local s = sc or awful.screen.focused()
|
local s = sc or awful.screen.focused()
|
||||||
|
|
||||||
for i = 1, #s.tags do
|
for _ = 1, #s.tags do
|
||||||
awful.tag.viewidx(direction, s)
|
awful.tag.viewidx(direction, s)
|
||||||
if #s.clients > 0 then
|
if #s.clients > 0 then
|
||||||
return
|
return
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local helpers = require("lain.helpers")
|
local helpers = require("lain.helpers")
|
||||||
local util = require("lain.util")
|
|
||||||
local atable = require("awful.util").table
|
local atable = require("awful.util").table
|
||||||
local assert = assert
|
local assert = assert
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
|
@ -42,8 +41,8 @@ end
|
||||||
-- * timeout: time to wait before confirming the menu selection
|
-- * timeout: time to wait before confirming the menu selection
|
||||||
-- * icon: icon to display in the notification of the chosen label
|
-- * icon: icon to display in the notification of the chosen label
|
||||||
local function iterate(menu, timeout, icon)
|
local function iterate(menu, timeout, icon)
|
||||||
local timeout = timeout or 4 -- default timeout for each menu entry
|
timeout = timeout or 4 -- default timeout for each menu entry
|
||||||
local icon = icon or nil -- icon to display on the menu
|
icon = icon or nil -- icon to display on the menu
|
||||||
|
|
||||||
-- Build the list of choices
|
-- Build the list of choices
|
||||||
if not state.index then
|
if not state.index then
|
||||||
|
|
|
@ -50,7 +50,7 @@ function quake:display()
|
||||||
|
|
||||||
if not client then
|
if not client then
|
||||||
-- The client does not exist, we spawn it
|
-- The client does not exist, we spawn it
|
||||||
cmd = string.format("%s %s %s", self.app,
|
local cmd = string.format("%s %s %s", self.app,
|
||||||
string.format(self.argname, self.name), self.extra)
|
string.format(self.argname, self.name), self.extra)
|
||||||
awful.spawn(cmd, { tag = self.screen.selected_tag })
|
awful.spawn(cmd, { tag = self.screen.selected_tag })
|
||||||
return
|
return
|
||||||
|
@ -89,8 +89,8 @@ function quake:display()
|
||||||
client.fullscreen = false
|
client.fullscreen = false
|
||||||
client.hidden = true
|
client.hidden = true
|
||||||
local ctags = client:tags()
|
local ctags = client:tags()
|
||||||
for i, t in pairs(ctags) do
|
for j, _ in pairs(ctags) do
|
||||||
ctags[i] = nil
|
ctags[j] = nil
|
||||||
end
|
end
|
||||||
client:tags(ctags)
|
client:tags(ctags)
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,17 +21,17 @@ function separators.arrow_right(col1, col2)
|
||||||
widget.col1 = col1
|
widget.col1 = col1
|
||||||
widget.col2 = col2
|
widget.col2 = col2
|
||||||
|
|
||||||
widget.fit = function(m, w, h)
|
widget.fit = function(_, _, _)
|
||||||
return separators.width, separators.height
|
return separators.width, separators.height
|
||||||
end
|
end
|
||||||
|
|
||||||
widget.update = function(col1, col2)
|
widget.update = function(_, _)
|
||||||
widget.col1 = col1
|
widget.col1 = col1
|
||||||
widget.col2 = col2
|
widget.col2 = col2
|
||||||
widget:emit_signal("widget::redraw_needed")
|
widget:emit_signal("widget::redraw_needed")
|
||||||
end
|
end
|
||||||
|
|
||||||
widget.draw = function(mycross, wibox, cr, width, height)
|
widget.draw = function(_, _, cr, width, height)
|
||||||
if widget.col2 ~= "alpha" then
|
if widget.col2 ~= "alpha" then
|
||||||
cr:set_source_rgb(gears.color.parse_color(widget.col2))
|
cr:set_source_rgb(gears.color.parse_color(widget.col2))
|
||||||
cr:new_path()
|
cr:new_path()
|
||||||
|
@ -69,7 +69,7 @@ function separators.arrow_left(col1, col2)
|
||||||
widget.col1 = col1
|
widget.col1 = col1
|
||||||
widget.col2 = col2
|
widget.col2 = col2
|
||||||
|
|
||||||
widget.fit = function(m, w, h)
|
widget.fit = function(_, _, _)
|
||||||
return separators.width, separators.height
|
return separators.width, separators.height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ function separators.arrow_left(col1, col2)
|
||||||
widget:emit_signal("widget::redraw_needed")
|
widget:emit_signal("widget::redraw_needed")
|
||||||
end
|
end
|
||||||
|
|
||||||
widget.draw = function(mycross, wibox, cr, width, height)
|
widget.draw = function(_, _, cr, width, height)
|
||||||
if widget.col1 ~= "alpha" then
|
if widget.col1 ~= "alpha" then
|
||||||
cr:set_source_rgb(gears.color.parse_color(widget.col1))
|
cr:set_source_rgb(gears.color.parse_color(widget.col1))
|
||||||
cr:new_path()
|
cr:new_path()
|
||||||
|
|
|
@ -15,7 +15,7 @@ local string = string
|
||||||
-- lain.widget.alsa
|
-- lain.widget.alsa
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
local alsa = { widget = args.widget or wibox.widget.textbox() }
|
local alsa = { widget = args.widget or wibox.widget.textbox() }
|
||||||
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
|
||||||
|
|
|
@ -30,13 +30,13 @@ local function factory(args)
|
||||||
_playback = "off"
|
_playback = "off"
|
||||||
}
|
}
|
||||||
|
|
||||||
local args = args or {}
|
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
|
||||||
local width = args.width or 63
|
local width = args.width or 63
|
||||||
local height = args.height or 1
|
local height = args.height or 1
|
||||||
local margins = args.margins or 1
|
local margins = args.margins or 1
|
||||||
local paddings = args.paddings or 1
|
|
||||||
local ticks = args.ticks or false
|
local ticks = args.ticks or false
|
||||||
local ticks_size = args.ticks_size or 7
|
local ticks_size = args.ticks_size or 7
|
||||||
local tick = args.tick or "|"
|
local tick = args.tick or "|"
|
||||||
|
@ -136,7 +136,7 @@ local function factory(args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
int = math.modf((alsabar._current_level / 100) * tot)
|
local int = math.modf((alsabar._current_level / 100) * tot)
|
||||||
preset.text = string.format(
|
preset.text = string.format(
|
||||||
"%s%s%s%s",
|
"%s%s%s%s",
|
||||||
tick_pre,
|
tick_pre,
|
||||||
|
|
|
@ -26,7 +26,8 @@ local function factory(args)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local bat = { widget = args.widget or wibox.widget.textbox() }
|
local bat = { widget = args.widget or wibox.widget.textbox() }
|
||||||
local timeout = args.timeout or 30
|
local timeout = args.timeout or 30
|
||||||
local notify = args.notify or "on"
|
local notify = args.notify or "on"
|
||||||
|
|
|
@ -150,7 +150,7 @@ local function factory(args)
|
||||||
|
|
||||||
function cal.hover_on() cal.show(0) end
|
function cal.hover_on() cal.show(0) end
|
||||||
function cal.move(offset)
|
function cal.move(offset)
|
||||||
local offset = offset or 0
|
offset = offset or 0
|
||||||
cal.month, cal.year = cal.getdate(cal.month, cal.year, offset)
|
cal.month, cal.year = cal.getdate(cal.month, cal.year, offset)
|
||||||
cal.show(0, cal.month, cal.year)
|
cal.show(0, cal.month, cal.year)
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,8 @@ local string = string
|
||||||
-- lain.widget.contrib.moc
|
-- lain.widget.contrib.moc
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local moc = { widget = args.widget or wibox.widget.textbox() }
|
local moc = { widget = args.widget or wibox.widget.textbox() }
|
||||||
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"
|
||||||
|
|
|
@ -15,7 +15,7 @@ local type = type
|
||||||
-- lain.widget.contrib.redshift
|
-- lain.widget.contrib.redshift
|
||||||
local redshift = { active = false, pid = nil }
|
local redshift = { active = false, pid = nil }
|
||||||
|
|
||||||
function redshift:start()
|
function redshift.start()
|
||||||
execute("pkill redshift")
|
execute("pkill redshift")
|
||||||
awful.spawn.with_shell("redshift -x") -- clear adjustments
|
awful.spawn.with_shell("redshift -x") -- clear adjustments
|
||||||
redshift.pid = awful.spawn.with_shell("redshift")
|
redshift.pid = awful.spawn.with_shell("redshift")
|
||||||
|
@ -25,14 +25,14 @@ function redshift:start()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function redshift:toggle()
|
function redshift.toggle()
|
||||||
async({ awful.util.shell, "-c", string.format("ps -p %d -o pid=", redshift.pid) }, function(f)
|
async({ awful.util.shell, "-c", string.format("ps -p %d -o pid=", redshift.pid) }, function(f)
|
||||||
if f and #f > 0 then -- redshift is running
|
if f and #f > 0 then -- redshift is running
|
||||||
-- Sending -USR1 toggles redshift (See project website)
|
-- Sending -USR1 toggles redshift (See project website)
|
||||||
execute("pkill -USR1 redshift")
|
execute("pkill -USR1 redshift")
|
||||||
redshift.active = not redshift.active
|
redshift.active = not redshift.active
|
||||||
else -- not started or killed, (re)start it
|
else -- not started or killed, (re)start it
|
||||||
redshift:start()
|
redshift.start()
|
||||||
end
|
end
|
||||||
redshift.update_fun(redshift.active)
|
redshift.update_fun(redshift.active)
|
||||||
end)
|
end)
|
||||||
|
@ -43,11 +43,11 @@ end
|
||||||
-- @param widget: Widget to attach to.
|
-- @param widget: Widget to attach to.
|
||||||
-- @param fun: Function to be run each time redshift is toggled (optional).
|
-- @param fun: Function to be run each time redshift is toggled (optional).
|
||||||
-- Use it to update widget text or icons on status change.
|
-- Use it to update widget text or icons on status change.
|
||||||
function redshift:attach(widget, fun)
|
function redshift.attach(widget, fun)
|
||||||
redshift.update_fun = fun or function() end
|
redshift.update_fun = fun or function() end
|
||||||
if not redshift.pid then redshift:start() end
|
if not redshift.pid then redshift.start() end
|
||||||
if widget then
|
if widget then
|
||||||
widget:buttons(awful.util.table.join(awful.button({}, 1, function () redshift:toggle() end)))
|
widget:buttons(awful.util.table.join(awful.button({}, 1, function () redshift.toggle() end)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ local markup = require("lain.util").markup
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local mouse = mouse
|
local mouse = mouse
|
||||||
local string = string
|
|
||||||
|
|
||||||
-- Taskwarrior notification
|
-- Taskwarrior notification
|
||||||
-- lain.widget.contrib.task
|
-- lain.widget.contrib.task
|
||||||
|
@ -69,7 +68,8 @@ function task.prompt()
|
||||||
end
|
end
|
||||||
|
|
||||||
function task.attach(widget, args)
|
function task.attach(widget, args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
task.show_cmd = args.show_cmd or "task next"
|
task.show_cmd = args.show_cmd or "task next"
|
||||||
task.prompt_text = args.prompt_text or "Enter task command: "
|
task.prompt_text = args.prompt_text or "Enter task command: "
|
||||||
task.followtag = args.followtag or false
|
task.followtag = args.followtag or false
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
local helpers = require("lain.helpers")
|
local helpers = require("lain.helpers")
|
||||||
local focused = require("awful.screen").focused
|
local focused = require("awful.screen").focused
|
||||||
local gears = require("gears")
|
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local string = string
|
local string = string
|
||||||
|
@ -61,7 +60,7 @@ local function factory(apipath)
|
||||||
local chem = tp_smapi.get(batid, "chemistry") or "no_chem"
|
local chem = tp_smapi.get(batid, "chemistry") or "no_chem"
|
||||||
local status = tp_smapi.get(batid, "state")
|
local status = tp_smapi.get(batid, "state")
|
||||||
local time = tp_smapi.time(batid)
|
local time = tp_smapi.time(batid)
|
||||||
local msg = ""
|
local msg
|
||||||
|
|
||||||
if status and status ~= "idle" then
|
if status and status ~= "idle" then
|
||||||
msg = string.format("[%s] %s %s", status, time ~= "N/A" and time or "unknown remaining time",
|
msg = string.format("[%s] %s %s", status, time ~= "N/A" and time or "unknown remaining time",
|
||||||
|
@ -80,7 +79,8 @@ local function factory(apipath)
|
||||||
end
|
end
|
||||||
|
|
||||||
function tp_smapi.create_widget(args)
|
function tp_smapi.create_widget(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local pspath = args.pspath or "/sys/class/power_supply/"
|
local pspath = args.pspath or "/sys/class/power_supply/"
|
||||||
local batteries = args.batteries or (args.battery and {args.battery}) or {}
|
local batteries = args.batteries or (args.battery and {args.battery}) or {}
|
||||||
local timeout = args.timeout or 30
|
local timeout = args.timeout or 30
|
||||||
|
@ -95,7 +95,7 @@ local function factory(apipath)
|
||||||
|
|
||||||
local all_batteries_installed = true
|
local all_batteries_installed = true
|
||||||
|
|
||||||
for i, battery in ipairs(batteries) do
|
for _, battery in ipairs(batteries) do
|
||||||
if not tp_smapi.installed(battery) then
|
if not tp_smapi.installed(battery) then
|
||||||
naughty.notify {
|
naughty.notify {
|
||||||
preset = naughty.config.critical,
|
preset = naughty.config.critical,
|
||||||
|
|
|
@ -10,13 +10,13 @@ local helpers = require("lain.helpers")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local math = math
|
local math = math
|
||||||
local string = string
|
local string = string
|
||||||
local tostring = tostring
|
|
||||||
|
|
||||||
-- CPU usage
|
-- CPU usage
|
||||||
-- lain.widget.cpu
|
-- lain.widget.cpu
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local cpu = { core = {}, widget = args.widget or wibox.widget.textbox() }
|
local cpu = { core = {}, widget = args.widget or wibox.widget.textbox() }
|
||||||
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
|
||||||
|
|
|
@ -17,7 +17,6 @@ local math = math
|
||||||
local string = string
|
local string = string
|
||||||
local tconcat = table.concat
|
local tconcat = table.concat
|
||||||
local type = type
|
local type = type
|
||||||
local tonumber = tonumber
|
|
||||||
local query_size = Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE
|
local query_size = Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE
|
||||||
local query_free = Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE
|
local query_free = Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE
|
||||||
local query_used = Gio.FILE_ATTRIBUTE_FILESYSTEM_USED
|
local query_used = Gio.FILE_ATTRIBUTE_FILESYSTEM_USED
|
||||||
|
@ -27,7 +26,8 @@ local query = query_size .. "," .. query_free .. "," .. query_used
|
||||||
-- lain.widget.fs
|
-- lain.widget.fs
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local fs = {
|
local fs = {
|
||||||
widget = args.widget or wibox.widget.textbox(),
|
widget = args.widget or wibox.widget.textbox(),
|
||||||
units = {
|
units = {
|
||||||
|
|
|
@ -17,7 +17,8 @@ local tonumber = tonumber
|
||||||
-- lain.widget.imap
|
-- lain.widget.imap
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local imap = { widget = args.widget or wibox.widget.textbox() }
|
local imap = { widget = args.widget or wibox.widget.textbox() }
|
||||||
local server = args.server
|
local server = args.server
|
||||||
local mail = args.mail
|
local mail = args.mail
|
||||||
|
|
|
@ -14,7 +14,8 @@ local gmatch, lines, floor = string.gmatch, io.lines, math.floor
|
||||||
-- lain.widget.mem
|
-- lain.widget.mem
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local mem = { widget = args.widget or wibox.widget.textbox() }
|
local mem = { widget = args.widget or wibox.widget.textbox() }
|
||||||
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
|
||||||
|
|
|
@ -19,7 +19,8 @@ local string = string
|
||||||
-- lain.widget.mpd
|
-- lain.widget.mpd
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local mpd = { widget = args.widget or wibox.widget.textbox() }
|
local mpd = { widget = args.widget or wibox.widget.textbox() }
|
||||||
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 ""
|
||||||
|
|
|
@ -15,7 +15,8 @@ local string = string
|
||||||
-- lain.widget.net
|
-- lain.widget.net
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local net = { widget = args.widget or wibox.widget.textbox(), devices = {} }
|
local net = { widget = args.widget or wibox.widget.textbox(), devices = {} }
|
||||||
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
|
||||||
|
|
|
@ -15,7 +15,8 @@ local type = type
|
||||||
-- lain.widget.pulse
|
-- lain.widget.pulse
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local pulse = { widget = args.widget or wibox.widget.textbox(), device = "N/A" }
|
local pulse = { widget = args.widget or wibox.widget.textbox(), device = "N/A" }
|
||||||
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
|
||||||
|
|
|
@ -32,7 +32,8 @@ local function factory(args)
|
||||||
device = "N/A"
|
device = "N/A"
|
||||||
}
|
}
|
||||||
|
|
||||||
local args = args or {}
|
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
|
||||||
local width = args.width or 63
|
local width = args.width or 63
|
||||||
|
@ -144,7 +145,7 @@ local function factory(args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
int = math.modf((pulsebar._current_level / 100) * tot)
|
local int = math.modf((pulsebar._current_level / 100) * tot)
|
||||||
preset.text = string.format(
|
preset.text = string.format(
|
||||||
"%s%s%s%s",
|
"%s%s%s%s",
|
||||||
tick_pre,
|
tick_pre,
|
||||||
|
|
|
@ -14,7 +14,8 @@ local open, match = io.open, string.match
|
||||||
-- lain.widget.sysload
|
-- lain.widget.sysload
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local sysload = { widget = args.widget or wibox.widget.textbox() }
|
local sysload = { widget = args.widget or wibox.widget.textbox() }
|
||||||
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
|
||||||
|
|
|
@ -13,7 +13,8 @@ local tonumber = tonumber
|
||||||
-- lain.widget.temp
|
-- lain.widget.temp
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local temp = { widget = args.widget or wibox.widget.textbox() }
|
local temp = { widget = args.widget or wibox.widget.textbox() }
|
||||||
local timeout = args.timeout or 30
|
local timeout = args.timeout or 30
|
||||||
local tempfile = args.tempfile or "/sys/devices/virtual/thermal/thermal_zone0/temp"
|
local tempfile = args.tempfile or "/sys/devices/virtual/thermal/thermal_zone0/temp"
|
||||||
|
|
|
@ -21,18 +21,17 @@ local tonumber = tonumber
|
||||||
-- lain.widget.weather
|
-- lain.widget.weather
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
local args = args or {}
|
args = args or {}
|
||||||
|
|
||||||
local weather = { widget = args.widget or wibox.widget.textbox() }
|
local weather = { widget = args.widget or wibox.widget.textbox() }
|
||||||
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain's default
|
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain's default
|
||||||
local timeout = args.timeout or 60 * 15 -- 15 min
|
local timeout = args.timeout or 60 * 15 -- 15 min
|
||||||
local timeout_forecast = args.timeout or 60 * 60 * 24 -- 24 hrs
|
|
||||||
local current_call = args.current_call or "curl -s 'https://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'"
|
local current_call = args.current_call or "curl -s 'https://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'"
|
||||||
local forecast_call = args.forecast_call or "curl -s 'https://api.openweathermap.org/data/2.5/forecast/daily?id=%s&units=%s&lang=%s&cnt=%s&APPID=%s'"
|
local forecast_call = args.forecast_call or "curl -s 'https://api.openweathermap.org/data/2.5/forecast/daily?id=%s&units=%s&lang=%s&cnt=%s&APPID=%s'"
|
||||||
local city_id = args.city_id or 0 -- placeholder
|
local city_id = args.city_id or 0 -- placeholder
|
||||||
local units = args.units or "metric"
|
local units = args.units or "metric"
|
||||||
local lang = args.lang or "en"
|
local lang = args.lang or "en"
|
||||||
local cnt = args.cnt or 5
|
local cnt = args.cnt or 5
|
||||||
local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'"
|
|
||||||
local icons_path = args.icons_path or helpers.icons_dir .. "openweathermap/"
|
local icons_path = args.icons_path or helpers.icons_dir .. "openweathermap/"
|
||||||
local notification_preset = args.notification_preset or {}
|
local notification_preset = args.notification_preset or {}
|
||||||
local notification_text_fun = args.notification_text_fun or
|
local notification_text_fun = args.notification_text_fun or
|
||||||
|
@ -91,8 +90,8 @@ local function factory(args)
|
||||||
function weather.forecast_update()
|
function weather.forecast_update()
|
||||||
local cmd = string.format(forecast_call, city_id, units, lang, cnt, APPID)
|
local cmd = string.format(forecast_call, city_id, units, lang, cnt, APPID)
|
||||||
helpers.async(cmd, function(f)
|
helpers.async(cmd, function(f)
|
||||||
local pos, err
|
local err
|
||||||
weather_now, pos, err = json.decode(f, 1, nil)
|
weather_now, _, err = json.decode(f, 1, nil)
|
||||||
|
|
||||||
if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then
|
if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then
|
||||||
weather.notification_text = ""
|
weather.notification_text = ""
|
||||||
|
@ -110,8 +109,8 @@ local function factory(args)
|
||||||
function weather.update()
|
function weather.update()
|
||||||
local cmd = string.format(current_call, city_id, units, lang, APPID)
|
local cmd = string.format(current_call, city_id, units, lang, APPID)
|
||||||
helpers.async(cmd, function(f)
|
helpers.async(cmd, function(f)
|
||||||
local pos, err, icon
|
local err
|
||||||
weather_now, pos, err = json.decode(f, 1, nil)
|
weather_now, _, err = json.decode(f, 1, nil)
|
||||||
|
|
||||||
if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then
|
if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then
|
||||||
local sunrise = tonumber(weather_now["sys"]["sunrise"])
|
local sunrise = tonumber(weather_now["sys"]["sunrise"])
|
||||||
|
|
Loading…
Add table
Reference in a new issue