widgets: guess display name for a given mountpoint

This commit is contained in:
Vincent Bernat 2012-12-13 08:29:33 +01:00
parent 98a8885069
commit 9de7485159

View file

@ -188,25 +188,29 @@ volwidget:buttons(awful.util.table.join(
awful.button({ }, 5, volume.decrease)))
-- File systems
local fs = { ["/"] = "root",
["/home"] = "home",
["/var"] = "var",
["/usr"] = "usr",
["/tmp"] = "tmp",
["/var/cache/build"] = "pbuilder" }
local fs = { "/",
"/home",
"/var",
"/usr",
"/tmp",
"/var/cache/build",
"/var/lib/mongodb",
"/var/lib/systems" }
local fsicon = widget({ type = "imagebox" })
fsicon.image = image(beautiful.icons .. "/widgets/disk.png")
local fswidget = widget({ type = "textbox" })
vicious.register(fswidget, vicious.widgets.fs,
function (widget, args)
local result = ""
for path, name in pairs(fs) do
for _, path in pairs(fs) do
local used = args["{" .. path .. " used_p}"]
local color = beautiful.fg_widget_value
if used then
if used > 90 then
color = beautiful.fg_widget_value_important
end
local name = string.gsub(path, "[%w/]*/(%w+)", "%1")
if name == "/" then name = "root" end
result = string.format(
'%s%s<span color="' .. beautiful.fg_widget_label .. '">%s: </span>' ..
'<span color="' .. color .. '">%2d%%</span>',