Major improvement to Awesome configs, fix keybinds and menu

This commit is contained in:
natemaia
2017-12-09 19:23:04 -08:00
parent 8a11bf9edd
commit e322152f69
70 changed files with 769 additions and 1136 deletions

View File

@ -1,35 +0,0 @@
#-*- mode: org -*-
#+TYP_TODO: TODO MAYBE CANCEL WAITING NEXT NOTE DONE
#+STARTUP: showall
#+STARTUP: hidestars
* Vicious
** TODO Implement intelligent multigraph support
** TODO Expand raid to grab data for all available devices
** TODO Consider commiting power drain support to bat.lua
** TODO Document contrib widgets in contrib/README
** TODO Complete the hddtemp fix
- In certain setups regexp does not match all devices
- The regexp catches the first device name, but last stats
- Shortening the match introduced new problems IIRC
** TODO Add fan speed to thermal.lua
** TODO Fix contrib/sensors for Ian
- > it does work and provides the lm_sensors
> information but only for one cpu core.
** TODO Return values of type number in NET and FS
- Note: tonumber() strips decimal points
** MAYBE Simplify scrolling using negative margins + fixed width
** TODO Try to simplify truncating with a fixed width
** NOTE Changelog header
---------------------------------------------------
Full changelog is available online:
http://git.sysphere.org/vicious/log/?showmsg=1
---------------------------------------------------
* Git
** DONE Git hook post-update not executed on git push
** DONE Git post-update hook does not leave info/refs with correct permissions
** DONE Git persmission are incorrect since 1.6.5, does not honor umask
** TODO Git smart http transport with cgit

View File

@ -16,8 +16,8 @@ local io = { open = io.open }
local setmetatable = setmetatable
local getmetatable = getmetatable
local string = {
upper = string.upper,
format = string.format
upper = string.upper,
format = string.format
}
-- }}}
@ -34,126 +34,126 @@ local scroller = {}
-- {{{ Helper functions
-- {{{ Loader of vicious modules
function helpers.wrequire(table, key)
local module = rawget(table, key)
return module or require(table._NAME .. "." .. key)
local module = rawget(table, key)
return module or require(table._NAME .. "." .. key)
end
-- }}}
-- {{{ Expose path as a Lua table
function helpers.pathtotable(dir)
return setmetatable({ _path = dir },
{ __index = function(table, index)
local path = table._path .. '/' .. index
local f = io.open(path)
if f then
local s = f:read("*all")
f:close()
if s then
return s
else
local o = { _path = path }
setmetatable(o, getmetatable(table))
return o
end
end
return setmetatable({ _path = dir },
{ __index = function(table, index)
local path = table._path .. '/' .. index
local f = io.open(path)
if f then
local s = f:read("*all")
f:close()
if s then
return s
else
local o = { _path = path }
setmetatable(o, getmetatable(table))
return o
end
end
})
end
})
end
-- }}}
-- {{{ Format a string with args
function helpers.format(format, args)
for var, val in pairs(args) do
format = format:gsub("$" .. (tonumber(var) and var or
var:gsub("[-+?*]", function(i) return "%"..i end)),
val)
end
for var, val in pairs(args) do
format = format:gsub("$" .. (tonumber(var) and var or
var:gsub("[-+?*]", function(i) return "%"..i end)),
val)
end
return format
return format
end
-- }}}
-- {{{ Format units to one decimal point
function helpers.uformat(array, key, value, unit)
for u, v in pairs(unit) do
array["{"..key.."_"..u.."}"] = string.format("%.1f", value/v)
end
for u, v in pairs(unit) do
array["{"..key.."_"..u.."}"] = string.format("%.1f", value/v)
end
return array
return array
end
-- }}}
-- {{{ Escape a string
function helpers.escape(text)
local xml_entities = {
["\""] = """,
["&"] = "&",
["'"] = "'",
["<"] = "&lt;",
[">"] = "&gt;"
}
local xml_entities = {
["\""] = "&quot;",
["&"] = "&amp;",
["'"] = "&apos;",
["<"] = "&lt;",
[">"] = "&gt;"
}
return text and text:gsub("[\"&'<>]", xml_entities)
return text and text:gsub("[\"&'<>]", xml_entities)
end
-- }}}
-- {{{ Escape a string for save usage on the command line
function helpers.shellquote(s)
if s == nil then return "" end
-- use single quotes, and put single quotes into double quotes
-- the string $'b is then quoted as '$'"'"'b'"'"'
return "'" .. s:gsub("'", "'\"'\"'") .. "'"
if s == nil then return "" end
-- use single quotes, and put single quotes into double quotes
-- the string $'b is then quoted as '$'"'"'b'"'"'
return "'" .. s:gsub("'", "'\"'\"'") .. "'"
end
-- }}}
-- {{{ Capitalize a string
function helpers.capitalize(text)
return text and text:gsub("([%w])([%w]*)", function(c, s)
return string.upper(c) .. s
end)
return text and text:gsub("([%w])([%w]*)", function(c, s)
return string.upper(c) .. s
end)
end
-- }}}
-- {{{ Truncate a string
function helpers.truncate(text, maxlen)
local txtlen = text:len()
local txtlen = text:len()
if txtlen > maxlen then
text = text:sub(1, maxlen - 3) .. "..."
end
if txtlen > maxlen then
text = text:sub(1, maxlen - 3) .. "..."
end
return text
return text
end
-- }}}
-- {{{ Scroll through a string
function helpers.scroll(text, maxlen, widget)
if not scroller[widget] then
scroller[widget] = { i = 1, d = true }
if not scroller[widget] then
scroller[widget] = { i = 1, d = true }
end
local txtlen = text:len()
local state = scroller[widget]
if txtlen > maxlen then
if state.d then
text = text:sub(state.i, state.i + maxlen) .. "..."
state.i = state.i + 3
if maxlen + state.i >= txtlen then
state.d = false
end
else
text = "..." .. text:sub(state.i, state.i + maxlen)
state.i = state.i - 3
if state.i <= 1 then
state.d = true
end
end
end
local txtlen = text:len()
local state = scroller[widget]
if txtlen > maxlen then
if state.d then
text = text:sub(state.i, state.i + maxlen) .. "..."
state.i = state.i + 3
if maxlen + state.i >= txtlen then
state.d = false
end
else
text = "..." .. text:sub(state.i, state.i + maxlen)
state.i = state.i - 3
if state.i <= 1 then
state.d = true
end
end
end
return text
return text
end
-- }}}